<html>
<head>
  <title>Evernote Export</title>
  <basefont face="微软雅黑" size="2" />
  <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
  <meta name="exporter-version" content="YXBJ Windows/603604 (zh-CN, DDL); Windows/10.0.0 (Win64); EDAMVersion=V2;"/>
  <style>
    body, td {
      font-family: 微软雅黑;
      font-size: 10pt;
    }
  </style>
</head>
<body>
<a name="1118"/>

<div>
<span><div><div><span style="font-size: 24pt;">00 - SpringCloud-Netflix 全家桶</span></div><div><font style="font-size: 24pt;"><br/></font></div><table bgcolor="#D4DDE5" border="0" width="100%"><colgroup><col></col></colgroup><tbody><tr><td><h1>01 - SpringCloud-NetFlix 理论知识一</h1><div><span style="font-weight: bold;">来源网址：</span> <a href="https://www.kuangstudy.com/bbs/1374942542566551554">https://www.kuangstudy.com/bbs/1374942542566551554</a></div><div><span style="font-weight: bold;">作者：</span> syra-</div></td></tr></tbody></table><div><br/></div></div><div><div><span style="font-size: 16pt;">01  -  SpringCloud-NetFlix 理论知识一 </span></div><div><br/></div><div><span style="font-size: 16pt;">官方doc : </span><a href="https://www.springcloud.cc/spring-cloud-dalston.html" style="font-size: 16pt;">https://www.springcloud.cc/spring-cloud-dalston.html</a></div><div><span style="font-size: 16pt;">博客笔记 ：</span><span style="font-size: 16pt;"><a href="https://www.kuangstudy.com/bbs/1374942542566551554" style="font-size: 16pt;">https://www.kuangstudy.com/bbs/1374942542566551554</a></span></div><div><span style="font-size: 16pt;">Gitee :   </span><a href="https://gitee.com/yujie.louis/springcloud-config" style="font-size: 16pt;">https://gitee.com/yujie.louis/springcloud-config</a></div><div><span style="font-size: 16pt;">Bilibili :  </span><a href="https://www.bilibili.com/video/BV1jJ411S7xr" style="font-size: 16pt;">https://www.bilibili.com/video/BV1jJ411S7xr</a></div><div><font style="font-size: 18pt;"><br/></font></div><div><font style="font-size: 18pt;"><span style="font-size: 18pt; color: rgb(255, 0, 0); font-weight: bold;">一、SpringCloud的五大组件</span></font></div><ul><li><div><span style="font-size: 16pt;">Netflix Eureka   -  服务注册与发现</span></div></li><li><div><span style="font-size: 16pt;">Netflix Ribbon  -  客户端负载均衡</span></div></li><ul><li><div><span style="font-size: 16pt;"> Feign  -  服务端负载均衡 (依赖Ribbon ,只是将调用方式RestTemplate 更改成Service 接口，社区版，更符合面向接口编程)</span></div></li></ul><li><div><span style="font-size: 16pt;">Netflix Hystrix  - 断路器</span></div></li><ul><li><div><span style="font-size: 21.3333px;">服务熔断</span></div></li><li><div><span style="font-size: 21.3333px;">服务降级</span></div></li></ul><li><div><span style="font-size: 16pt;">Netflix Zuul  -  路由，服务网关</span></div></li><li><div><span style="font-size: 21.3333px;">SpringCloud  Config - 分布式配置</span></div></li></ul><div><span style="font-size: 16pt;"><br/></span></div><div><span style="font-size: 21.3333px;">常见面试题：</span></div><div><br/></div><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><font style="font-size: 16pt;">1.1 什么是微服务？</font></div><div><font style="font-size: 16pt;">1.2 微服务之间是如何独立通讯的？</font></div><div><font style="font-size: 16pt;">1.3 SpringCloud 和 Dubbo有那些区别？</font></div><div><font style="font-size: 16pt;">1.4 SpringBoot 和 SpringCloud，请谈谈你对他们的理解</font></div><div><font style="font-size: 16pt;">1.5 什么是服务熔断？什么是服务降级？</font></div><div><font style="font-size: 16pt;">1.6 微服务的优缺点分别是什么？说下你在项目开发中遇到的坑</font></div><div><font style="font-size: 16pt;">1.7 你所知道的微服务技术栈有哪些？列举一二</font></div><div><font style="font-size: 16pt;">1.8 Eureka和Zookeeper都可以提供服务注册与发现的功能，请说说两者的区别</font></div></div><div><span style="font-size: 16pt;"><br/></span></div><div><br/></div><div><span style="font-size: 18pt; color: rgb(255, 0, 0); font-weight: bold;">二、微服务概述</span></div><h4 style="box-sizing: border-box; padding: 0px; margin: 1em 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Microsoft Yahei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.4;">2.1 什么是微服务？</span></span></h4><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">微服务(Microservice Architecture) 是近几年流行的一种架构思想，关于它的概念很难一言以蔽之。</span></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">究竟什么是微服务呢？我们在此引用ThoughtWorks 公司的首席科学家 Martin Fowler 于2014年提出的一段话：</span></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><font style="font-size: 16pt;">原文：https://martinfowler.com/articles/microservices.html</font></div><div><font style="font-size: 16pt;">汉化：https://www.cnblogs.com/liuning8023/p/4493156.html</font></div></div></div><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important; text-align: left;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">就目前而言，对于微服务，业界并没有一个统一的，标准的定义。</span></span></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important; text-align: left;"><span style="font-size: 16pt; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); color: unset; font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif;">但通常而言，微服务架构是一种架构模式，或者说是一种架构风格，</span><span style="font-size: 16pt; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); border-radius: 20px; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-weight: bold;">它将单一的应用程序（All in one）划分成一组小的服务</span><span style="font-size: 16pt; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); color: unset; font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif;">，每个服务运行在其独立的自己的进程内，服务之间互相协调，互相配置，为用户提供最终价值，服务之间采用轻量级的通信机制(</span><span style="font-size: 16pt; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); border-radius: 20px; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-weight: bold;">HTTP</span><span style="font-size: 16pt; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); color: unset; font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif;">)互相沟通，每个服务都围绕着具体的业务进行构建，并且能够被独立的部署到生产环境中，另外，应尽量避免统一的，集中式的服务管理机制，对具体的一个服务而言，应该根据业务上下文，选择合适的语言，工具(</span><span style="font-size: 16pt; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); border-radius: 20px; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-weight: bold;">Maven</span><span style="font-size: 16pt; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); color: unset; font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif;">)对其进行构建，可以有一个非常轻量级的集中式管理来协调这些服务，可以使用不同的语言来编写服务，也可以使用不同的数据存储。</span></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt; font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">微服务化的核心就是将传统的一站式应用，根据业务拆分成一个一个的服务，彻底地去耦合，每一个微服务提供单个业务功能的服务，一个服务做一件事情，从技术角度看就是一种小而独立的处理过程，类似进程的概念，能够自行单独启动或销毁，拥有自己独立的数据库。</span></span></div></li></ul><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"></div><h4 style="box-sizing: border-box; padding: 0px; margin: 1em 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Microsoft Yahei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.4;">2.2 微服务与微服务架构</span></span></h4><blockquote style="box-sizing: border-box; padding: 10px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); border-left: 4px solid rgb(139, 195, 74); background: rgb(248, 248, 248); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div style="box-sizing: border-box; padding: 0px; margin: 0px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt; color: rgb(102, 102, 102); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">微服务</span></span></div></blockquote><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">强调的是服务的大小，它关注的是某一个点，是具体解决某一个问题/提供落地对应服务的一个服务应用，狭义的看，可以看作是IDEA中的一个个微服务工程，或者Moudel。IDEA 工具里面使用Maven开发的一个个独立的小Moudel，它具体是使用SpringBoot开发的一个小模块，专业的事情交给专业的模块来做，一个模块就做着一件事情。强调的是一个个的个体，每个个体完成一个具体的任务或者功能。</span></span></div><blockquote style="box-sizing: border-box; padding: 10px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); border-left: 4px solid rgb(139, 195, 74); background: rgb(248, 248, 248); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div style="box-sizing: border-box; padding: 0px; margin: 0px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt; color: rgb(102, 102, 102); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">微服务架构</span></span></div></blockquote><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">一种新的架构形式，Martin Fowler 于2014年提出。</span></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">微服务架构是一种架构模式，它体长将单一应用程序划分成一组小的服务，服务之间相互协调，互相配合，为用户提供最终价值。每个服务运行在其独立的进程中，服务与服务之间采用轻量级的通信机制(如HTTP)</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">互相协作，每个服务都围绕着具体的业务进行构建，并且能够被独立的部署到生产环境中，另外，应尽量避免统一的，集中式的服务管理机制，对具体的一个服务而言，应根据业务上下文，选择合适的语言、工具</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">(如Maven)对其进行构建。</span></font></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"></div><h4 style="box-sizing: border-box; padding: 0px; margin: 1em 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Microsoft Yahei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.4;">2.3 微服务优缺点</span></span></h4><blockquote style="box-sizing: border-box; padding: 10px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); border-left: 4px solid rgb(139, 195, 74); background: rgb(248, 248, 248); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div style="box-sizing: border-box; padding: 0px; margin: 0px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt; color: rgb(102, 102, 102); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">优点</span></span></div></blockquote><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">单一职责原则；</span></span></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">每个服务足够内聚，足够小，代码容易理解，这样能聚焦一个指定的业务功能或业务需求；</span></span></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">开发简单，开发效率高，一个服务可能就是专一的只干一件事；</span></span></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">微服务能够被小团队单独开发，这个团队只需2-5个开发人员组成；</span></span></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">微服务是松耦合的，是有功能意义的服务，无论是在开发阶段或部署阶段都是独立的；</span></span></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">微服务能使用不同的语言开发；</span></span></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">易于和第三方集成，微服务允许容易且灵活的方式集成自动部署，通过持续集成工具，如jenkins，Hudson，bamboo；</span></span></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">微服务易于被一个开发人员理解，修改和维护，这样小团队能够更关注自己的工作成果，无需通过合作才能体现价值；</span></span></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">微服务允许利用和融合最新技术；</span></span></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); border-radius: 20px;"><span style="font-size: 16pt; color: rgb(24, 24, 24); font-weight: bold;">微服务只是业务逻辑的代码，不会和HTML，CSS，或其他的界面混合;</span></span></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); border-radius: 20px;"><span style="font-size: 16pt; color: rgb(24, 24, 24); font-weight: bold;">每个微服务都有自己的存储能力，可以有自己的数据库，也可以有统一的数据库；</span></span></div></li></ul><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"></div><blockquote style="box-sizing: border-box; padding: 10px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); border-left: 4px solid rgb(139, 195, 74); background: rgb(248, 248, 248); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div style="box-sizing: border-box; padding: 0px; margin: 0px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt; color: rgb(102, 102, 102); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">缺点</span></span></div></blockquote><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important; text-align: left;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">开发人员要处理分布式系统的复杂性；</span></span></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important; text-align: left;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">多服务运维难度，随着服务的增加，运维的压力也在增大；</span></span></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important; text-align: left;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">系统部署依赖问题；</span></span></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important; text-align: left;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">服务间通信成本问题；</span></span></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important; text-align: left;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">数据一致性问题；</span></span></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important; text-align: left;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">系统集成测试问题；</span></span></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">性能和监控问题；</span></font></div></li></ul><h4 style="box-sizing: border-box; padding: 0px; margin: 1em 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Microsoft Yahei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.4;">2.4 微服务技术栈有那些？</span></span></h4><div><span style="font-size: 11pt;"><span style="font-size: 11pt; color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;; font-weight: bold;">|  **微服务技术条目**           | 落地技术                                                             |</span></span></div><div><span style="font-size: 11pt;"><span style="font-size: 11pt; color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;; font-weight: bold;">| -----------------</span></span><span style="font-size: 11pt; color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;; font-weight: bold;">-------</span><span style="font-size: 11pt;"><span style="font-size: 11pt; color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;; font-weight: bold;">---   | ------------------------------------------------    |</span></span></div><div><span style="font-size: 11pt;"><span style="font-size: 11pt; color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;; font-weight: bold;">| 服务开发                             | SpringBoot、Spring、SpringMVC等               |</span></span></div><div><span style="font-size: 11pt;"><span style="font-size: 11pt; color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;; font-weight: bold;">| 服务配置与管理                   | Netfix公司的Archaius、阿里的Diamond等       |</span></span></div><div><span style="font-size: 11pt;"><span style="font-size: 11pt; color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;; font-weight: bold;">| 服务注册与发现                   | Eureka、Consul、Zookeeper等                        |</span></span></div><div><span style="font-size: 11pt;"><span style="font-size: 11pt; color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;; font-weight: bold;">| 服务调用                             | Rest、PRC、gRPC                                             |</span></span></div><div><span style="font-size: 11pt;"><span style="font-size: 11pt; color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;; font-weight: bold;">| 服务熔断器                          | Hystrix、Envoy等                                              |</span></span></div><div><span style="font-size: 11pt;"><span style="font-size: 11pt; color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;; font-weight: bold;">| 负载均衡                             | Ribbon、Nginx等                                              |</span></span></div><div><span style="font-size: 11pt;"><span style="font-size: 11pt; color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;; font-weight: bold;">| 服务接口调用(客户端调用服务的简化工具) | Fegin等                                         |</span></span></div><div><span style="font-size: 11pt;"><span style="font-size: 11pt; color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;; font-weight: bold;">| 消息队列                             | Kafka、RabbitMQ、ActiveMQ等                      |</span></span></div><div><span style="font-size: 11pt;"><span style="font-size: 11pt; color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;; font-weight: bold;">| 服务配置中心管理               | SpringCloudConfig、Chef等                             |</span></span></div><div><span style="font-size: 11pt;"><span style="font-size: 11pt; color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;; font-weight: bold;">| 服务路由(API网关)              | Zuul等                                                                |</span></span></div><div><span style="font-size: 11pt;"><span style="font-size: 11pt; color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;; font-weight: bold;">| 服务监控                             | Zabbix、Nagios、Metrics、Specatator等       |</span></span></div><div><span style="font-size: 11pt;"><span style="font-size: 11pt; color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;; font-weight: bold;">| 全链路追踪                          | Zipkin、Brave、Dapper等                                |</span></span></div><div><span style="font-size: 11pt;"><span style="font-size: 11pt; color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;; font-weight: bold;">| 数据流操作开发包                | SpringCloud Stream(封装与Redis，Rabbit，Kafka等发送接收消息) |</span></span></div><div><span style="font-size: 11pt;"><span style="font-size: 11pt; color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;; font-weight: bold;">| 时间消息总栈                       | SpringCloud Bus                                               |</span></span></div><div><span style="font-size: 11pt;"><span style="font-size: 11pt; color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;; font-weight: bold;">| 服务部署                              | Docker、OpenStack、Kubernetes等               |</span></span></div><div><span style="font-size: 11pt;"><br/></span></div><div><span style="font-size: 18pt; color: rgb(255, 0, 0); font-weight: bold;">三、SpingCloud 入门概述</span></div><h4 style="box-sizing: border-box; padding: 0px; margin: 1em 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Microsoft Yahei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.4;">3.1 SpringCloud是什么？</span></span></h4><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">Spring官网：</span><a href="https://spring.io/" style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background: transparent; font-size: 16pt; color: rgb(65, 131, 196); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">https://spring.io/</a></font></div><div style="text-align: center; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"><img src="./index/Image.png" type="image/png" data-filename="Image.png" style="font-family:" width="751"/></span></div><div style="text-align: center; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;;"><img src="./index/Image [1].png" type="image/png" data-filename="Image.png" width="761"/></span></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"></div><h4 style="box-sizing: border-box; padding: 0px; margin: 1em 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Microsoft Yahei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.4;">3.2 SpringCloud和SpringBoot的关系</span></span></h4><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important; text-align: left;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">SpringBoot专注于开发方便的开发单个个体微服务；</span></span></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important; text-align: left;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">SpringCloud是关注全局的微服务协调整理治理框架，它将SpringBoot开发的一个个单体微服务，整合并管理起来，为各个微服务之间提供：配置管理、服务发现、断路器、路由、为代理、事件总栈、全局锁、决策竞选、分布式会话等等集成服务；</span></span></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important; text-align: left;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">SpringBoot可以离开SpringCloud独立使用，开发项目，但SpringCloud离不开SpringBoot，属于依赖关系；</span></span></div></li><li><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;">SpringBoot专注于快速、方便的开发单个个体微服务，SpringCloud关注全局的服务治理框架；</span></font></div></li></ul><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"></div><h4 style="box-sizing: border-box; padding: 0px; margin: 1em 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Microsoft Yahei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.4;">3.3 Dubbo 和 SpringCloud技术选型</span></span></h4><h5 style="box-sizing: border-box; padding: 0px; margin: 1em 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.4;">1. 分布式+服务治理Dubbo</span></span></h5><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">目前成熟的互联网架构，应用服务化拆分 + 消息中间件</span></span></div></li></ul><h5 style="box-sizing: border-box; padding: 0px; margin: 1em 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.4;">2. Dubbo 和 SpringCloud对比</span></span></h5><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">可以看一下社区活跃度：</span></span></div><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><font style="font-size: 16pt;">https://github.com/dubbo</font></div><div><font style="font-size: 16pt;">https://github.com/spring-cloud</font></div></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br/></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; border-radius: 20px;"><span style="font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">最大区别：Spring Cloud 抛弃了Dubbo的RPC通信，采用的是基于HTTP的REST方式</span></span></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">严格来说，这两种方式各有优劣。虽然从一定程度上来说，后者牺牲了服务调用的性能，但也避免了上面提到的原生RPC带来的问题。而且REST相比RPC更为灵活，服务提供方和调用方的依赖只依靠一纸契约，不存在代码级别的强依赖，这个优点在当下强调快速演化的微服务环境下，显得更加合适。</span></font></div></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="font-size: 16pt; color: rgb(227, 0, 0); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">总结：二者解决的问题域不一样：Dubbo的定位是一款RPC框架，而SpringCloud的目标是微服务架构下的一站式解决方案。</span></font></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">官网：</span></font><span style="font-size: 16pt;"><a href="https://spring.io/projects/spring-cloud#learn" style="font-size: 16pt; font-family: &quot;Microsoft YaHei&quot;;">https://spring.io/projects/spring-cloud#learn</a></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">版本号有点特别：</span></span></div><div style="text-align: center; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;; font-variant-caps: normal; font-variant-ligatures: normal;"><img src="./index/Image [2].png" type="image/png" data-filename="Image.png" width="629"/></span></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">SpringCloud没有采用数字编号的方式命名版本号，而是采用了伦敦地铁站的名称，</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">同时根据字母表的顺序来对应版本时间顺序</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">，比如最早的Realse版本：Angel，第二个Realse版本：Brixton，然后是Camden、Dalston、Edgware，目前最新的是Hoxton SR12 CURRENT GA通用稳定版。</span></font></div><div><br/></div><div><div><br/></div><table bgcolor="#D4DDE5" border="0" width="100%"><colgroup><col></col></colgroup><tbody><tr><td><h1>02 - SpringCloud Rest 学习环境搭建 ： 服务提供者</h1><div><span style="font-weight: bold;">来源网址：</span> <a href="https://www.kuangstudy.com/bbs/1374942542566551554">https://www.kuangstudy.com/bbs/1374942542566551554</a></div><div><span style="font-weight: bold;">作者：</span> syra-</div></td></tr></tbody></table><div><br/></div></div><div><div><span style="font-size: 18pt;">02 - SpringCloud Rest 学习环境搭建 ： 服务提供者  </span></div><div><font style="font-size: 16pt;"><br/></font></div><div><span style="font-size: 16pt;"> Springcloud-provider-dept-8001、springcloud-consumer-dept-80、springcloud-api</span></div><div><br/></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;">我们会使用一个Dept部门模块做一个微服务通用案例</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-weight: bold;">Consumer</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;">消费者(</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-weight: bold;">Client</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;">)通过REST调用</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-weight: bold;">Provider</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;">提供者(</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-weight: bold;">Server</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;">)提供的服务。</span></font></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;"><br/></span></font></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><span style="font-size: 16pt;">一、父子工程</span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;">1.版本控制</span></font></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><br/></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><font style="font-size: 16pt;">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</font></div><div><font style="font-size: 16pt;">&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot;</font></div><div><font style="font-size: 16pt;">         xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</font></div><div><font style="font-size: 16pt;">         xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;</font></div><div><font style="font-size: 16pt;">    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">    &lt;groupId&gt;cn.edu.zzu&lt;/groupId&gt;</font></div><div><font style="font-size: 16pt;">    &lt;artifactId&gt;TestSpringCloud01&lt;/artifactId&gt;</font></div><div><font style="font-size: 16pt;">    &lt;packaging&gt;pom&lt;/packaging&gt;</font></div><div><font style="font-size: 16pt;">    &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;</font></div><div><font style="font-size: 16pt;">    &lt;modules&gt;</font></div><div><font style="font-size: 16pt;">        &lt;module&gt;Springcloud-provider-dept-8001&lt;/module&gt;</font></div><div><font style="font-size: 16pt;">        &lt;module&gt;Springcloud-api&lt;/module&gt;</font></div><div><font style="font-size: 16pt;">        &lt;module&gt;Springcloud-consumer-dept-80&lt;/module&gt;</font></div><div><font style="font-size: 16pt;">        &lt;module&gt;Springcloud-Eureka-7001&lt;/module&gt;</font></div><div><font style="font-size: 16pt;">        &lt;module&gt;Springcloud-Eureka-7002&lt;/module&gt;</font></div><div><font style="font-size: 16pt;">        &lt;module&gt;SpringCloud-Eureka-7003&lt;/module&gt;</font></div><div><font style="font-size: 16pt;">        &lt;module&gt;Springcloud-provider-dept-8002&lt;/module&gt;</font></div><div><font style="font-size: 16pt;">        &lt;module&gt;Springcloud-provider-dept-8003&lt;/module&gt;</font></div><div><font style="font-size: 16pt;">        &lt;module&gt;Springcloud-consumer-dept-feign-80&lt;/module&gt;</font></div><div><font style="font-size: 16pt;">        &lt;module&gt;Springcloud-provider-dept-hystrix-8001&lt;/module&gt;</font></div><div><font style="font-size: 16pt;">        &lt;module&gt;Springcloud-consumer-dept-hystrix-dashboard-9001&lt;/module&gt;</font></div><div><font style="font-size: 16pt;">        &lt;module&gt;Springcloud-zuul-9527&lt;/module&gt;</font></div><div><font style="font-size: 16pt;">        &lt;module&gt;Springcloud-config-server-3344&lt;/module&gt;</font></div><div><font style="font-size: 16pt;">        &lt;module&gt;Springcloud-config-client-8001&lt;/module&gt;</font></div><div><font style="font-size: 16pt;">        &lt;module&gt;Springcloud-config-eureka-7001&lt;/module&gt;</font></div><div><font style="font-size: 16pt;">        &lt;module&gt;Springcloud-config-provider-dept-8001&lt;/module&gt;</font></div><div><font style="font-size: 16pt;">    &lt;/modules&gt;</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">    &lt;properties&gt;</font></div><div><font style="font-size: 16pt;">        &lt;maven.compiler.source&gt;8&lt;/maven.compiler.source&gt;</font></div><div><font style="font-size: 16pt;">        &lt;maven.compiler.target&gt;8&lt;/maven.compiler.target&gt;</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">        &lt;!--版本管理--&gt;</font></div><div><font style="font-size: 16pt;">        &lt;lombok.version&gt;1.18.20&lt;/lombok.version&gt;</font></div><div><font style="font-size: 16pt;">        &lt;junit.version&gt;4.13.2&lt;/junit.version&gt;</font></div><div><font style="font-size: 16pt;">        &lt;log4j.version&gt;1.2.17&lt;/log4j.version&gt;</font></div><div><font style="font-size: 16pt;">        &lt;myqsl.version&gt;5.1.48&lt;/myqsl.version&gt;</font></div><div><font style="font-size: 16pt;">    &lt;/properties&gt;</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">    &lt;dependencyManagement&gt;</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">        &lt;!--</font></div><div><font style="font-size: 16pt;">        依赖的版本冲突问题，推荐：</font></div><div><font style="font-size: 16pt;">            1、SpringCloud： Hoxton.SR8</font></div><div><font style="font-size: 16pt;">            2、SpringBoot：2.3.3.RELEASE</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">        以下版本全为：2.2.5.RELEASE</font></div><div><font style="font-size: 16pt;">            3、服务者：pring-cloud-starter-netflix-eureka-client</font></div><div><font style="font-size: 16pt;">            4、Eureka：spring-cloud-starter-netflix-eureka-server</font></div><div><font style="font-size: 16pt;">            5、消费者+Ribbon：spring-cloud-starter-netflix-eureka-client</font></div><div><font style="font-size: 16pt;">                spring-cloud-starter-netflix-ribbon</font></div><div><font style="font-size: 16pt;">            6、Feign:spring-cloud-starter-openfeign</font></div><div><font style="font-size: 16pt;">            7、Hystrix：spring-cloud-starter-netflix-hystrix</font></div><div><font style="font-size: 16pt;">               spring-cloud-starter-netflix-hystrix-dashboard</font></div><div><font style="font-size: 16pt;">            8、zuul：spring-cloud-starter-netflix-zuul</font></div><div><font style="font-size: 16pt;">        版本推荐可以看spring cloud官网里面全都有</font></div><div><font style="font-size: 16pt;">        --&gt;</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">        &lt;dependencies&gt;</font></div><div><font style="font-size: 16pt;">            &lt;dependency&gt;</font></div><div><font style="font-size: 16pt;">                &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;</font></div><div><font style="font-size: 16pt;">                &lt;artifactId&gt;spring-cloud-alibaba-dependencies&lt;/artifactId&gt;</font></div><div><font style="font-size: 16pt;">                &lt;version&gt;0.2.0.RELEASE&lt;/version&gt;</font></div><div><font style="font-size: 16pt;">                &lt;type&gt;pom&lt;/type&gt;</font></div><div><font style="font-size: 16pt;">                &lt;scope&gt;import&lt;/scope&gt;</font></div><div><font style="font-size: 16pt;">            &lt;/dependency&gt;</font></div><div><font style="font-size: 16pt;">            &lt;!--springCloud的依赖--&gt;</font></div><div><font style="font-size: 16pt;">            &lt;dependency&gt;</font></div><div><font style="font-size: 16pt;">                &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;</font></div><div><font style="font-size: 16pt;">                &lt;artifactId&gt;spring-cloud-dependencies&lt;/artifactId&gt;</font></div><div><font style="font-size: 16pt;">                &lt;version&gt;Greenwich.SR1&lt;/version&gt;</font></div><div><font style="font-size: 16pt;">                &lt;type&gt;pom&lt;/type&gt;</font></div><div><font style="font-size: 16pt;">                &lt;scope&gt;import&lt;/scope&gt;</font></div><div><font style="font-size: 16pt;">            &lt;/dependency&gt;</font></div><div><font style="font-size: 16pt;">            &lt;!--SpringBoot--&gt;</font></div><div><font style="font-size: 16pt;">            &lt;dependency&gt;</font></div><div><font style="font-size: 16pt;">                &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;</font></div><div><font style="font-size: 16pt;">                &lt;artifactId&gt;spring-boot-dependencies&lt;/artifactId&gt;</font></div><div><font style="font-size: 16pt;">                &lt;version&gt;2.1.4.RELEASE&lt;/version&gt;</font></div><div><font style="font-size: 16pt;">                &lt;type&gt;pom&lt;/type&gt;</font></div><div><font style="font-size: 16pt;">                &lt;scope&gt;import&lt;/scope&gt;</font></div><div><font style="font-size: 16pt;">            &lt;/dependency&gt;</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">            &lt;!--mysql数据库驱动--&gt;</font></div><div><font style="font-size: 16pt;">            &lt;dependency&gt;</font></div><div><font style="font-size: 16pt;">                &lt;groupId&gt;mysql&lt;/groupId&gt;</font></div><div><font style="font-size: 16pt;">                &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;</font></div><div><font style="font-size: 16pt;">                &lt;version&gt;${myqsl.version}&lt;/version&gt;</font></div><div><font style="font-size: 16pt;">            &lt;/dependency&gt;</font></div><div><font style="font-size: 16pt;">            &lt;!--alibaba 数据源--&gt;</font></div><div><font style="font-size: 16pt;">            &lt;dependency&gt;</font></div><div><font style="font-size: 16pt;">                &lt;groupId&gt;com.alibaba&lt;/groupId&gt;</font></div><div><font style="font-size: 16pt;">                &lt;artifactId&gt;druid&lt;/artifactId&gt;</font></div><div><font style="font-size: 16pt;">                &lt;version&gt;1.2.6&lt;/version&gt;</font></div><div><font style="font-size: 16pt;">            &lt;/dependency&gt;</font></div><div><font style="font-size: 16pt;">            &lt;!--日志测试~--&gt;</font></div><div><font style="font-size: 16pt;">            &lt;dependency&gt;</font></div><div><font style="font-size: 16pt;">                &lt;groupId&gt;ch.qos.logback&lt;/groupId&gt;</font></div><div><font style="font-size: 16pt;">                &lt;artifactId&gt;logback-core&lt;/artifactId&gt;</font></div><div><font style="font-size: 16pt;">                &lt;version&gt;1.2.3&lt;/version&gt;</font></div><div><font style="font-size: 16pt;">            &lt;/dependency&gt;</font></div><div><font style="font-size: 16pt;">            &lt;!--log4j--&gt;</font></div><div><font style="font-size: 16pt;">            &lt;dependency&gt;</font></div><div><font style="font-size: 16pt;">                &lt;groupId&gt;log4j&lt;/groupId&gt;</font></div><div><font style="font-size: 16pt;">                &lt;artifactId&gt;log4j&lt;/artifactId&gt;</font></div><div><font style="font-size: 16pt;">                &lt;version&gt;${log4j.version}&lt;/version&gt;</font></div><div><font style="font-size: 16pt;">            &lt;/dependency&gt;</font></div><div><font style="font-size: 16pt;">            &lt;!--test 大于4.12--&gt;</font></div><div><font style="font-size: 16pt;">            &lt;dependency&gt;</font></div><div><font style="font-size: 16pt;">                &lt;groupId&gt;junit&lt;/groupId&gt;</font></div><div><font style="font-size: 16pt;">                &lt;artifactId&gt;junit&lt;/artifactId&gt;</font></div><div><font style="font-size: 16pt;">                &lt;version&gt;${junit.version}&lt;/version&gt;</font></div><div><font style="font-size: 16pt;">                &lt;scope&gt;test&lt;/scope&gt;</font></div><div><font style="font-size: 16pt;">            &lt;/dependency&gt;</font></div><div><font style="font-size: 16pt;">            &lt;!--pojo插件getset Lombok--&gt;</font></div><div><font style="font-size: 16pt;">            &lt;dependency&gt;</font></div><div><font style="font-size: 16pt;">                &lt;groupId&gt;org.projectlombok&lt;/groupId&gt;</font></div><div><font style="font-size: 16pt;">                &lt;artifactId&gt;lombok&lt;/artifactId&gt;</font></div><div><font style="font-size: 16pt;">                &lt;version&gt;${lombok.version}&lt;/version&gt;</font></div><div><font style="font-size: 16pt;">            &lt;/dependency&gt;</font></div><div><font style="font-size: 16pt;">        &lt;/dependencies&gt;</font></div><div><font style="font-size: 16pt;">    &lt;/dependencyManagement&gt;</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">&lt;/project&gt;</font></div></div><div><br/></div></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><h4 style="box-sizing: border-box; padding: 0px; margin: 1em 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Microsoft Yahei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.4;">2. SpringCloud版本选择</span></span></h4><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 14px; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 17px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; border-radius: 20px; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">大版本说明</span></div><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><font style="font-size: 16pt;">| SpringBoot | SpringCloud | 关系 |</font></div><div><font style="font-size: 16pt;">| ---------- | ----------------- | ---------------------------------- |</font></div><div><font style="font-size: 16pt;">| 1.2.x | Angel版本(天使) | 兼容SpringBoot1.2x |</font></div><div><font style="font-size: 16pt;">| 1.3.x | Brixton版本(布里克斯顿) | 兼容SpringBoot1.3x，也兼容SpringBoot1.4x |</font></div><div><font style="font-size: 16pt;">| 1.4.x | Camden版本(卡姆登) | 兼容SpringBoot1.4x，也兼容SpringBoot1.5x |</font></div><div><font style="font-size: 16pt;">| 1.5.x | Dalston版本(多尔斯顿) | 兼容SpringBoot1.5x，不兼容SpringBoot2.0x |</font></div><div><font style="font-size: 16pt;">| 1.5.x | Edgware版本(埃奇韦尔) | 兼容SpringBoot1.5x，不兼容SpringBoot2.0x |</font></div><div><font style="font-size: 16pt;">| 2.0.x | Finchley版本(芬奇利) | 兼容SpringBoot2.0x，不兼容SpringBoot1.5x |</font></div><div><font style="font-size: 16pt;">| 2.1.x | Greenwich版本(格林威治) | |</font></div></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; list-style: decimal; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><br/></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 14px; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 17px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; border-radius: 20px; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">实际开发版本关系</span></div><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><font style="font-size: 16pt;">| spring-boot-starter-parent | | spring-cloud-dependencles | |</font></div><div><font style="font-size: 16pt;">|:--------------------------:| --------:|:-------------------------:|:--------:|</font></div><div><font style="font-size: 16pt;">| **版本号** | **发布日期** | **版本号** | **发布日期** |</font></div><div><font style="font-size: 16pt;">| 1.5.2.RELEASE | 2017-03 | Dalston.RC1 | 2017-x |</font></div><div><font style="font-size: 16pt;">| 1.5.9.RELEASE | 2017-11 | Edgware.RELEASE | 2017-11 |</font></div><div><font style="font-size: 16pt;">| 1.5.16.RELEASE | 2018-04 | Edgware.SR5 | 2018-10 |</font></div><div><font style="font-size: 16pt;">| 1.5.20.RELEASE | 2018-09 | Edgware.SR5 | 2018-10 |</font></div><div><font style="font-size: 16pt;">| 2.0.2.RELEASE | 2018-05 | Fomchiey.BULD-SNAPSHOT | 2018-x |</font></div><div><font style="font-size: 16pt;">| 2.0.6.RELEASE | 2018-10 | Fomchiey-SR2 | 2018-10 |</font></div><div><font style="font-size: 16pt;">| 2.1.4.RELEASE | 2019-04 | Greenwich.SR1 | 2019-03 |</font></div></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; list-style: decimal; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><br/></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;">3.模块</span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">父工程为springcloud，其下有多个子mudule，详情参考完整代码了解</span></span></div><div style="text-align: center; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"><img src="./index/Image [3].png" type="image/png" data-filename="Image.png" style="box-sizing: border-box; padding: 15px; margin: 5px 0px; list-style: none; vertical-align: middle; border: 0px; max-width: 100%; height: auto; background: rgb(255, 255, 255); box-shadow: rgb(219, 219, 219) 0px 0px 12px inset; cursor: zoom-in;"/></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">springcloud-consumer-dept-80访问springcloud-provider-dept-8001下的controller使用REST方式</span></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><span style="font-size: 21.3333px; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif;">二、RestTemplate使用</span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><br/></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">1.配置ConfigBean，在容器中注入RestTemplate</span></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><br/></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"><font style="font-size: 16pt;">package cn.edu.zzu.config;</font></span></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"><font style="font-size: 16pt;">import com.netflix.loadbalancer.*;</font></span></div><div><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"><font style="font-size: 16pt;">import org.springframework.cloud.client.loadbalancer.LoadBalanced;</font></span></div><div><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"><font style="font-size: 16pt;">import org.springframework.context.annotation.Bean;</font></span></div><div><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"><font style="font-size: 16pt;">import org.springframework.context.annotation.Configuration;</font></span></div><div><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"><font style="font-size: 16pt;">import org.springframework.web.client.RestTemplate;</font></span></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"><font style="font-size: 16pt;">@Configuration</font></span></div><div><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"><font style="font-size: 16pt;">public class ConfigBean {</font></span></div><div><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"><font style="font-size: 16pt;">    @Bean</font></span></div><div><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"><font style="font-size: 16pt;">    public RestTemplate getRestemplate() {</font></span></div><div><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"><font style="font-size: 16pt;">        return new RestTemplate();</font></span></div><div><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"><font style="font-size: 16pt;">    }</font></span></div><div><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"><font style="font-size: 16pt;">}</font></span></div></div><div><br/></div></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">2.使用RestTemplate的http方法请求服务提供者中的服务模块</span></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><br/></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"><font style="font-size: 16pt;">package cn.edu.zzu.controller;</font></span></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"><font style="font-size: 16pt;">import cn.edu.zzu.domain.Dept;</font></span></div><div><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"><font style="font-size: 16pt;">import org.springframework.beans.factory.annotation.Autowired;</font></span></div><div><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"><font style="font-size: 16pt;">import org.springframework.web.bind.annotation.*;</font></span></div><div><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"><font style="font-size: 16pt;">import org.springframework.web.client.RestTemplate;</font></span></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"><font style="font-size: 16pt;">import java.util.List;</font></span></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"><font style="font-size: 16pt;">@RestController</font></span></div><div><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"><font style="font-size: 16pt;">@RequestMapping(&quot;/consumer/dept&quot;)</font></span></div><div><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"><font style="font-size: 16pt;">public class Deptcontroller {</font></span></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"><font style="font-size: 16pt;">    @Autowired</font></span></div><div><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"><font style="font-size: 16pt;">    RestTemplate restTemplate;</font></span></div><div><font style="font-size: 16pt;"><br/></font></div><div><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"><font style="font-size: 16pt;">    /*请求路径*/</font></span></div><div><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"><font style="font-size: 16pt;">    private static final String URL_PATH = &quot;http://localhost:8001&quot;;</font></span></div><div><font style="font-size: 16pt;"><br/></font></div><div><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"><font style="font-size: 16pt;">    @GetMapping(&quot;/get/{id}&quot;)</font></span></div><div><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"><font style="font-size: 16pt;">    public Dept findDeptById(@PathVariable(&quot;id&quot;) Long id){</font></span></div><div><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"><font style="font-size: 16pt;">        return restTemplate.getForObject(URL_PATH+&quot;/dept/get/&quot;+id , Dept.class);</font></span></div><div><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"><font style="font-size: 16pt;">    }</font></span></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"><font style="font-size: 16pt;">    @PostMapping(&quot;/addDept&quot;)</font></span></div><div><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"><font style="font-size: 16pt;">    public boolean addDept(Dept dept){</font></span></div><div><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"><font style="font-size: 16pt;">        return restTemplate.postForObject(URL_PATH+&quot;/dept/addDept&quot; , dept , Boolean.class);</font></span></div><div><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"><font style="font-size: 16pt;">    }</font></span></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"><font style="font-size: 16pt;">    @GetMapping(&quot;/findAll&quot;)</font></span></div><div><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"><font style="font-size: 16pt;">    public List&lt;Dept&gt; findAll(){</font></span></div><div><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"><font style="font-size: 16pt;">        return restTemplate.getForObject(URL_PATH+&quot;/dept/getAll&quot; ,List.class);</font></span></div><div><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"><font style="font-size: 16pt;">    }</font></span></div><div><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"><font style="font-size: 16pt;">}</font></span></div></div><div><br/></div></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div></div><div><br/></div><div><br/></div><div><div><br/></div><table bgcolor="#D4DDE5" border="0" width="100%"><colgroup><col></col></colgroup><tbody><tr><td><h1>03 - SpringCloud Eureka 学习环境搭建 ： 注册中心 （单机/集群）</h1><div><span style="font-weight: bold;">来源网址：</span> <a href="https://www.kuangstudy.com/bbs/1374942542566551554">https://www.kuangstudy.com/bbs/1374942542566551554</a></div><div><span style="font-weight: bold;">作者：</span> syra-</div></td></tr></tbody></table><div><br/></div></div><div><div><span style="font-size: 18pt; color: unset; font-family: unset;">03 - SpringCloud Eureka 学习环境搭建 ：  注册中心 （单机/集群） </span></div><div><font style="font-size: 16pt;"><br/></font></div><div><span style="font-size: 16pt;">springcloud-Eureka-7001/2/3</span><span style="font-size: 16pt;">、springcloud-provider-dept-8001(集成eurekaclient)</span></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><span style="font-size: 16pt; color: rgb(255, 0, 0); font-weight: bold;">一、理论介绍</span></font></div><h4 style="box-sizing: border-box; padding: 0px; margin: 1em 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Microsoft Yahei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.4;">1. </span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Microsoft Yahei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.4;">什么是Eureka</span></font></h4><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">Netflix在涉及Eureka时，遵循的就是API原则.</span></span></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">Eureka是Netflix的有个子模块，也是核心模块之一。Eureka是基于REST的服务，用于定位服务，以实现云端中间件层服务发现和故障转移，服务注册与发现对于微服务来说是非常重要的，有了服务注册与发现，只需要使用服务的标识符，就可以访问到服务，而不需要修改服务调用的配置文件了，功能类似于Dubbo的注册中心，比如Zookeeper.</span></span></div></li></ul><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt; font-weight: bold;">2.</span></span><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Microsoft Yahei&quot;, sans-serif; font-weight: bold;">原理理解</span></font></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><div style="box-sizing: border-box; padding: 0px; margin: 16px 0px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); border-radius: 20px;"><span style="font-size: 16pt; color: rgb(24, 24, 24); font-weight: bold;">Eureka基本的架构</span></span></div><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">Springcloud 封装了Netflix公司开发的Eureka模块来实现服务注册与发现 (对比Zookeeper).</span></span></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">Eureka采用了C-S的架构设计，EurekaServer作为服务注册功能的服务器，他是服务注册中心.</span></span></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">而系统中的其他微服务，使用Eureka的客户端连接到EurekaServer并维持心跳连接。这样系统的维护人员就可以通过EurekaServer来监控系统中各个微服务是否正常运行，Springcloud 的一些其他模块 (比如Zuul) 就可以通过EurekaServer来发现系统中的其他微服务，并执行相关的逻辑.</span></span></div></li></ul></div><div style="text-align: center;"><span style="font-size: 16pt;"><img src="./index/Image [4].png" type="image/png" data-filename="Image.png" width="667"/></span></div><div style="text-align: center;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: center;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: left;"><font style="font-size: 16pt;"><span style="font-size: 16pt; font-weight: bold;">对比dubbo架构</span></font></div><div style="text-align: center;"><span style="font-size: 16pt;"><img src="./index/Image [5].png" type="image/png" data-filename="Image.png" width="733"/></span></div><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important; text-align: left;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;">Eureka 包含两个组件：</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-weight: bold;">Eureka Server</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;"> </span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;">和</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;"> </span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-weight: bold;">Eureka Client</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;">.</span></font></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important; text-align: left;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">Eureka Server 提供服务注册，各个节点启动后，回在EurekaServer中进行注册，这样Eureka Server中的服务注册表中将会储存所有可用服务节点的信息，服务节点的信息可以在界面中直观的看到.</span></span></div></li><li><div style="text-align: left;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;">Eureka Client 是一个Java客户端，用于简化EurekaServer的交互，客户端同时也具备一个内置的，使用轮询负载算法的负载均衡器。在应用启动后，将会向EurekaServer发送心跳 (默认周期为30秒) 。如果Eureka Server在多个心跳周期内没有接收到某个节点的心跳，EurekaServer将会从服务注册表中把这个服务节点移除掉 (默认周期为90s).</span></font></div></li></ul><div style="text-align: left;"><font style="font-size: 16pt;"><br/></font></div><div style="box-sizing: border-box; padding: 0px; margin: 16px 0px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); text-align: left;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); border-radius: 20px;"><span style="font-size: 16pt; color: rgb(24, 24, 24); font-weight: bold;">三大角色</span></span></div><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important; text-align: left;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">Eureka Server：提供服务的注册与发现</span></span></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important; text-align: left;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">Service Provider：服务生产方，将自身服务注册到Eureka中，从而使服务消费方能狗找到</span></span></div></li><li><div style="text-align: left;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;">Service Consumer：服务消费方，从Eureka中获取注册服务列表，从而找到消费服务</span></font></div></li></ul><div style="text-align: left;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: left;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: left;"><span style="font-size: 16pt; color: rgb(255, 0, 0); font-weight: bold;">二、构建EurekaServer-7001(Default port:8761) (下面是集群配置，确保集群中eurekaserver能够找到其他server即可；单机配置单节点url信息即可)</span></div><div style="text-align: left;"><span style="font-size: 16pt;"> </span></div><div style="text-align: left;"><span style="font-size: 16pt; font-weight: bold;">1.pom.xml</span></div><div style="text-align: left;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: left;"><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><font style="font-size: 16pt;">&lt;dependencies&gt;</font></div><div><font style="font-size: 16pt;">    &lt;!--导入Eureka Server依赖--&gt;</font></div><div><font style="font-size: 16pt;">    &lt;dependency&gt;</font></div><div><font style="font-size: 16pt;">        &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;</font></div><div><font style="font-size: 16pt;">        &lt;artifactId&gt;spring-cloud-starter-eureka-server&lt;/artifactId&gt;</font></div><div><font style="font-size: 16pt;">        &lt;version&gt;1.4.7.RELEASE&lt;/version&gt;</font></div><div><font style="font-size: 16pt;">    &lt;/dependency&gt;</font></div><div><font style="font-size: 16pt;">    &lt;!--热部署工具--&gt;</font></div><div><font style="font-size: 16pt;">    &lt;dependency&gt;</font></div><div><font style="font-size: 16pt;">        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;</font></div><div><font style="font-size: 16pt;">        &lt;artifactId&gt;spring-boot-devtools&lt;/artifactId&gt;</font></div><div><font style="font-size: 16pt;">    &lt;/dependency&gt;</font></div><div><font style="font-size: 16pt;">&lt;/dependencies&gt;</font></div></div><div><font style="font-size: 16pt;"><br/></font></div></div><div style="text-align: left;"><font style="font-size: 16pt;"><span style="font-size: 16pt; font-weight: bold;">2.application.yml</span></font></div><div style="text-align: left;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: left;"><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><font style="font-size: 16pt;">server:</font></div><div><font style="font-size: 16pt;">  port: 7001</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">#eureka</font></div><div><font style="font-size: 16pt;">eureka:</font></div><div><font style="font-size: 16pt;">  instance:</font></div><div><font style="font-size: 16pt;">    hostname: eureka7001.com</font></div><div><font style="font-size: 16pt;">  client:</font></div><div><font style="font-size: 16pt;">    register-with-eureka: false #表示是否想eureka注册中心注册自己</font></div><div><font style="font-size: 16pt;">    fetch-registry:  false # fetch-registry = false表示自己为注册中心</font></div><div><font style="font-size: 16pt;">    #监控页面</font></div><div><font style="font-size: 16pt;">    service-url:</font></div><div><font style="font-size: 16pt;">      #集群</font></div><div><font style="font-size: 16pt;">      defaultZone:  http://eureka7002.com:7002/eureka/,http://eureka7003.com:7003/eureka/</font></div><div><font style="font-size: 16pt;">      #单机</font></div><div><font style="font-size: 16pt;">      #defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/ #this.serviceUrl.put(&quot;defaultZone&quot;, &quot;http://localhost:8761/eureka/&quot;);</font></div><div><font style="font-size: 16pt;">  server:</font></div><div><font style="font-size: 16pt;">    enable-self-preservation: false #禁止自我保护机制，不推荐！</font></div></div></div><div style="text-align: left;"><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">源码中Eureka的默认端口以及访问路径:</span></span></div><div style="text-align: center;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;;"><img src="./index/Image [6].png" type="image/png" data-filename="Image.png" width="917"/></span></div><div style="text-align: left;"><span style="font-size: 16pt;">Eureka集群环境</span></div><div style="text-align: center;"><img src="./index/Image [7].png" type="image/png" data-filename="Image.png"/></div><div style="text-align: left;"><span style="font-size: 16pt;">本机进行hosts映射配置，模拟真实环境：</span></div><div style="text-align: center;"><img src="./index/Image [8].png" type="image/png" data-filename="Image.png" width="525"/></div><div style="text-align: left;"><br/></div><div style="text-align: left;"><span style="font-size: 16pt; font-weight: bold;">3.主启动类</span></div><div style="text-align: left;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: left;"><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><font style="font-size: 16pt;">package cn.edu.zzu;</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">import org.springframework.boot.SpringApplication;</font></div><div><font style="font-size: 16pt;">import org.springframework.boot.autoconfigure.SpringBootApplication;</font></div><div><font style="font-size: 16pt;">import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">@EnableEurekaServer //服务端启动类，可以接受别的服务注册</font></div><div><font style="font-size: 16pt;">@SpringBootApplication</font></div><div><font style="font-size: 16pt;">public class EurekaServer_7001 {</font></div><div><font style="font-size: 16pt;">    public static void main(String[] args) {</font></div><div><font style="font-size: 16pt;">        SpringApplication.run(EurekaServer_7001.class, args);</font></div><div><font style="font-size: 16pt;">    }</font></div><div><font style="font-size: 16pt;">}</font></div></div><div><font style="font-size: 16pt;"><br/></font></div></div><div style="text-align: left;"><font style="font-size: 16pt;"><span style="font-size: 16pt; font-weight: bold;">4.</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;">启动成功后访问</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;"> </span><a href="http://localhost:7001/" style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); background: transparent; font-size: 16pt; color: rgb(65, 131, 196);">http://localhost:7001/</a><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;"> </span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;">得到以下页面</span></font></div><div style="text-align: left;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: center;"><span style="font-size: 16pt;"><img src="./index/Image [9].png" type="image/png" data-filename="Image.png" width="994"/></span></div><div style="text-align: left;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: left;"><span style="font-size: 16pt; color: rgb(255, 0, 0); font-weight: bold;">三、构建EurekaClient - Dept-provider-8001</span></div><div style="text-align: left;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: left;"><span style="font-size: 16pt; font-weight: bold;">1.pom.xml 依赖</span></div><div style="text-align: left;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: left;"><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><font style="font-size: 16pt;">&lt;dependencies&gt;</font></div><div><font style="font-size: 16pt;">    &lt;!--actuator 执行机构，eureka中服务信息提示需要该包   info:--&gt;</font></div><div><font style="font-size: 16pt;">    &lt;dependency&gt;</font></div><div><font style="font-size: 16pt;">        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;</font></div><div><font style="font-size: 16pt;">        &lt;artifactId&gt;spring-boot-starter-actuator&lt;/artifactId&gt;</font></div><div><font style="font-size: 16pt;">    &lt;/dependency&gt;</font></div><div><font style="font-size: 16pt;">    &lt;!--eureka 客户端--&gt;</font></div><div><font style="font-size: 16pt;">    &lt;dependency&gt;</font></div><div><font style="font-size: 16pt;">        &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;</font></div><div><font style="font-size: 16pt;">        &lt;artifactId&gt;spring-cloud-starter-eureka&lt;/artifactId&gt;</font></div><div><font style="font-size: 16pt;">        &lt;version&gt;1.4.7.RELEASE&lt;/version&gt;</font></div><div><font style="font-size: 16pt;">    &lt;/dependency&gt;</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">    &lt;dependency&gt;</font></div><div><font style="font-size: 16pt;">        &lt;groupId&gt;cn.edu.zzu&lt;/groupId&gt;</font></div><div><font style="font-size: 16pt;">        &lt;artifactId&gt;Springcloud-api&lt;/artifactId&gt;</font></div><div><font style="font-size: 16pt;">        &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;</font></div><div><font style="font-size: 16pt;">    &lt;/dependency&gt;</font></div><div><font style="font-size: 16pt;">    &lt;dependency&gt;</font></div><div><font style="font-size: 16pt;">        &lt;groupId&gt;mysql&lt;/groupId&gt;</font></div><div><font style="font-size: 16pt;">        &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;</font></div><div><font style="font-size: 16pt;">    &lt;/dependency&gt;</font></div><div><font style="font-size: 16pt;">    &lt;dependency&gt;</font></div><div><font style="font-size: 16pt;">        &lt;groupId&gt;com.alibaba&lt;/groupId&gt;</font></div><div><font style="font-size: 16pt;">        &lt;artifactId&gt;druid&lt;/artifactId&gt;</font></div><div><font style="font-size: 16pt;">    &lt;/dependency&gt;</font></div><div><font style="font-size: 16pt;">    &lt;dependency&gt;</font></div><div><font style="font-size: 16pt;">        &lt;groupId&gt;junit&lt;/groupId&gt;</font></div><div><font style="font-size: 16pt;">        &lt;artifactId&gt;junit&lt;/artifactId&gt;</font></div><div><font style="font-size: 16pt;">        &lt;scope&gt;test&lt;/scope&gt;</font></div><div><font style="font-size: 16pt;">    &lt;/dependency&gt;</font></div><div><font style="font-size: 16pt;">    &lt;dependency&gt;</font></div><div><font style="font-size: 16pt;">        &lt;groupId&gt;ch.qos.logback&lt;/groupId&gt;</font></div><div><font style="font-size: 16pt;">        &lt;artifactId&gt;logback-core&lt;/artifactId&gt;</font></div><div><font style="font-size: 16pt;">    &lt;/dependency&gt;</font></div><div><font style="font-size: 16pt;">    &lt;dependency&gt;</font></div><div><font style="font-size: 16pt;">        &lt;groupId&gt;org.mybatis.spring.boot&lt;/groupId&gt;</font></div><div><font style="font-size: 16pt;">        &lt;artifactId&gt;mybatis-spring-boot-starter&lt;/artifactId&gt;</font></div><div><font style="font-size: 16pt;">        &lt;version&gt;2.2.0&lt;/version&gt;</font></div><div><font style="font-size: 16pt;">    &lt;/dependency&gt;</font></div><div><font style="font-size: 16pt;">    &lt;dependency&gt;</font></div><div><font style="font-size: 16pt;">        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;</font></div><div><font style="font-size: 16pt;">        &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;</font></div><div><font style="font-size: 16pt;">    &lt;/dependency&gt;</font></div><div><font style="font-size: 16pt;">&lt;/dependencies&gt;</font></div></div><div><font style="font-size: 16pt;"><br/></font></div></div><div style="text-align: left;"><span style="font-size: 16pt; font-weight: bold;">2.application.yml</span></div><div style="text-align: left;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: left;"><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><font style="font-size: 16pt;">server:</font></div><div><font style="font-size: 16pt;">  port: 8001</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">#mybatis配置</font></div><div><font style="font-size: 16pt;">mybatis:</font></div><div><font style="font-size: 16pt;">  type-aliases-package: cn.edu.zzu.domain</font></div><div><font style="font-size: 16pt;">  config-location: classpath:SqlMapConfig.xml</font></div><div><font style="font-size: 16pt;">  mapper-locations: classpath:mybatis/mapper/*.xml</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">#spring</font></div><div><font style="font-size: 16pt;">spring:</font></div><div><font style="font-size: 16pt;">  application:</font></div><div><font style="font-size: 16pt;">    name: springcloud-provider-dept</font></div><div><font style="font-size: 16pt;">  datasource:</font></div><div><font style="font-size: 16pt;">    type: com.alibaba.druid.pool.DruidDataSource</font></div><div><font style="font-size: 16pt;">    driver-class-name: org.gjt.mm.mysql.Driver</font></div><div><font style="font-size: 16pt;">    url: jdbc:mysql:///db01?useUnicode=true&amp;characterEncoding=UTF-8</font></div><div><font style="font-size: 16pt;">    username: root</font></div><div><font style="font-size: 16pt;">    password: 123456</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">#eureka配置</font></div><div><font style="font-size: 16pt;">eureka:</font></div><div><font style="font-size: 16pt;">  client:</font></div><div><font style="font-size: 16pt;">    service-url:</font></div><div><font style="font-size: 16pt;">     defaultZone: http://eureka7001.com:7001/eureka/,http://eureka7002.com:7002/eureka/,http://eureka7003.com:7003/eureka/</font></div><div><font style="font-size: 16pt;">  instance:</font></div><div><font style="font-size: 16pt;">    instance-id: springcloud-provider-8001 #修改eureka的默认配置信息</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">#actuator</font></div><div><font style="font-size: 16pt;">info:</font></div><div><font style="font-size: 16pt;">  app.name: zzu_test_springCloud</font></div><div><font style="font-size: 16pt;">  company.name: zzu_company</font></div></div><div><font style="font-size: 16pt;"><br/></font></div></div><div style="text-align: left;"><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(0, 0, 0); font-family: 微软雅黑; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">3.主启动类</span></span></div><div style="text-align: left;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: left;"><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><font style="font-size: 16pt;">package cn.edu.zzu;</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">import org.springframework.boot.SpringApplication;</font></div><div><font style="font-size: 16pt;">import org.springframework.boot.autoconfigure.SpringBootApplication;</font></div><div><font style="font-size: 16pt;">import org.springframework.cloud.client.discovery.EnableDiscoveryClient;</font></div><div><font style="font-size: 16pt;">import org.springframework.cloud.netflix.eureka.EnableEurekaClient;</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">@SpringBootApplication</font></div><div><font style="font-size: 16pt;">@EnableEurekaClient   // 开启Eureka客户端注解，在服务启动后自动向注册中心注册服务</font></div><div><font style="font-size: 16pt;">@EnableDiscoveryClient</font><font style="font-size: 16pt;">// 开启服务发现客户端的注解，可以用来获取一些配置的信息，得到具体的微服务</font></div><div><font style="font-size: 16pt;">public class DeptProvider_8001{</font></div><div><font style="font-size: 16pt;">    public static void main(String[] args) {</font></div><div><font style="font-size: 16pt;">        SpringApplication.run(DeptProvider_8001.class ,args);</font></div><div><font style="font-size: 16pt;">    }</font></div><div><font style="font-size: 16pt;">}</font></div></div><div><font style="font-size: 16pt;"><br/></font></div></div><div style="text-align: left;"><font style="font-size: 16pt;"><span style="font-size: 16pt; font-weight: bold;">4.</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;">启动成功刷新EurekaServer</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;"> </span><a href="http://localhost:7001/" style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); background: transparent; font-size: 16pt; color: rgb(65, 131, 196);">http://localhost:7001/</a><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;"> </span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;">得到以下页面</span></font></div><div style="text-align: left;"></div><div style="text-align: center;"><span style="font-size: 16pt;"><img src="./index/Image [10].png" type="image/png" data-filename="Image.png" width="1115"/></span></div><div style="text-align: left;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: left;"><span style="font-size: 16pt;">访问服务信息页面，可以拿到info信息：</span></div><div style="text-align: left;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: center;"><span style="font-size: 16pt;"><img src="./index/Image [11].png" type="image/png" data-filename="Image.png"/></span></div><p style="box-sizing: border-box; padding: 0px; margin: 16px 0px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"></p><div style="text-align: left;"><span style="font-size: 16pt;">结果如图：</span></div><div style="margin-top: 1em; margin-bottom: 1em; text-align: left;"><span style="font-size: 16pt;"><img src="./index/Image [12].png" type="image/png" data-filename="Image.png" style="box-sizing: border-box; padding: 15px; margin: 5px 0px; list-style: none; vertical-align: middle; border: 0px; max-width: 100%; height: auto; background: rgb(255, 255, 255); box-shadow: rgb(219, 219, 219) 0px 0px 12px inset; cursor: zoom-in;"/></span></div><p style="text-align: left;"></p><p style="box-sizing: border-box; padding: 0px; margin: 16px 0px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"></p><div style="text-align: left;"><span style="font-size: 16pt;">如果此时停掉springcloud-provider-dept-8001 等</span><span style="box-sizing: border-box; border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-weight: bold;">30s</span><span style="font-size: 16pt;">后 监控会开启保护机制：</span></div><div style="margin-top: 1em; margin-bottom: 1em; text-align: left;"><span style="font-size: 16pt;"><img src="./index/Image [13].png" type="image/png" data-filename="Image.png" style="box-sizing: border-box; padding: 15px; margin: 5px 0px; list-style: none; vertical-align: middle; border: 0px; max-width: 100%; height: auto; background: rgb(255, 255, 255); box-shadow: rgb(219, 219, 219) 0px 0px 12px inset; cursor: zoom-in;"/></span></div><div style="text-align: left;"></div><h5 style="box-sizing: border-box; padding: 0px; margin: 1em 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.4;">5. EureKa自我保护机制：好死不如赖活着</span></span></h5><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">一句话总结就是：</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">某时刻某一个微服务不可用，eureka不会立即清理，依旧会对该微服务的信息进行保存！</span></font></div></li><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important; text-align: left;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;">默认情况下，当eureka server在一定时间内没有收到实例的心跳，便会把该实例从注册表中删除（</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-weight: bold;">默认是90秒</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;">），但是，如果短时间内丢失大量的实例心跳，便会触发eureka server的自我保护机制，比如在开发测试时，需要频繁地重启微服务实例，但是我们很少会把eureka server一起重启（因为在开发过程中不会修改eureka注册中心），</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-weight: bold;">当一分钟内收到的心跳数大量减少时，会触发该保护机制</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;">。可以在eureka管理界面看到Renews threshold和Renews(last min)，当后者（最后一分钟收到的心跳数）小于前者（心跳阈值）的时候，触发保护机制，会出现红色的警告：</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); overflow-wrap: break-word; background: rgb(246, 246, 246); border-radius: 3px; border: 1px solid rgb(238, 238, 238); font-size: 16pt; color: rgb(232, 62, 140); font-family: &quot;YaHei Consolas Hybrid&quot;, Consolas, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Helvetica, monospace, monospace;">EMERGENCY!EUREKA MAY BE INCORRECTLY CLAIMING INSTANCES ARE UP WHEN THEY'RE NOT.RENEWALS ARE LESSER THAN THRESHOLD AND HENCE THE INSTANCES ARE NOT BEGING EXPIRED JUST TO BE SAFE.</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;">从警告中可以看到，eureka认为虽然收不到实例的心跳，但它认为实例还是健康的，eureka会保护这些实例，不会把它们从注册表中删掉。</span></font></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important; text-align: left;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">该保护机制的目的是避免网络连接故障，在发生网络故障时，微服务和注册中心之间无法正常通信，但服务本身是健康的，不应该注销该服务，如果eureka因网络故障而把微服务误删了，那即使网络恢复了，该微服务也不会重新注册到eureka server了，因为只有在微服务启动的时候才会发起注册请求，后面只会发送心跳和服务列表请求，这样的话，该实例虽然是运行着，但永远不会被其它服务所感知。所以，eureka server在短时间内丢失过多的客户端心跳时，会进入自我保护模式，该模式下，eureka会保护注册表中的信息，不在注销任何微服务，当网络故障恢复后，eureka会自动退出保护模式。自我保护模式可以让集群更加健壮。</span></span></font></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important; text-align: left;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;">但是我们在开发测试阶段，需要频繁地重启发布，如果触发了保护机制，则旧的服务实例没有被删除，这时请求有可能跑到旧的实例中，而该实例已经关闭了，这就导致请求错误，影响开发测试。所以，在开发测试阶段，我们可以把自我保护模式关闭，只需在eureka server配置文件中加上如下配置即可：</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); overflow-wrap: break-word; background: rgb(246, 246, 246); border-radius: 3px; border: 1px solid rgb(238, 238, 238); font-size: 16pt; color: rgb(232, 62, 140); font-family: &quot;YaHei Consolas Hybrid&quot;, Consolas, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Helvetica, monospace, monospace;">eureka.server.enable-self-preservation=false</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;">【不推荐关闭自我保护机制】</span></font></div></li><li><div style="text-align: left;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">详细内容可以参考下这篇博客内容：</span><a href="https://blog.csdn.net/wudiyong22/article/details/80827594" style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background: transparent; font-size: 16pt; color: rgb(65, 131, 196); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">https://blog.csdn.net/wudiyong22/article/details/80827594</a></font></div></li></ul></ul><div style="text-align: left;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: left;"><font style="font-size: 16pt;"><span style="font-size: 16pt; font-weight: bold;">6.</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.4;">注册进来的微服务，获取一些消息（团队开发会用到）</span></font></div><div style="text-align: left;"></div><h5 style="box-sizing: border-box; padding: 0px; margin: 1em 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.4;">1.DeptController.java新增如何拿到注册中心的服务信息</span></h5><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><font style="font-size: 16pt;">   //获取eureka中的信息</font></div><div><font style="font-size: 16pt;">    @Autowired</font></div><div><font style="font-size: 16pt;">    private DiscoveryClient discoveryClient;</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">     @GetMapping(&quot;/discover&quot;)</font></div><div><font style="font-size: 16pt;">    public Object discover() {</font></div><div><font style="font-size: 16pt;">        //获取微服务的列表清单</font></div><div><font style="font-size: 16pt;">        List&lt;String&gt; services = discoveryClient.getServices();</font></div><div><font style="font-size: 16pt;">        System.out.println(&quot;discover==&gt;services&quot; + services);</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">        //获取一个具体的服务实例信息</font></div><div><font style="font-size: 16pt;">        List&lt;ServiceInstance&gt; instances = discoveryClient.getInstances(&quot;SPRINGCLOUD-PROVIDER-DEPT-8001&quot;);</font></div><div><font style="font-size: 16pt;">        System.out.println(&quot;discover==&gt;instances&quot; + instances);</font></div><div><font style="font-size: 16pt;">        for (ServiceInstance instance : instances) {</font></div><div><font style="font-size: 16pt;">            System.out.println(</font></div><div><font style="font-size: 16pt;">                    &quot;Host:&quot; + instance.getHost() +</font></div><div><font style="font-size: 16pt;">                            &quot;  Port:&quot; + instance.getPort() +</font></div><div><font style="font-size: 16pt;">                            &quot;  ServiceId：&quot;+instance.getServiceId()+</font></div><div><font style="font-size: 16pt;">                            &quot;  Uri:&quot;+instance.getUri()+</font></div><div><font style="font-size: 16pt;">                            &quot;  InstanceId:&quot; + instance.getInstanceId()</font></div><div><font style="font-size: 16pt;">            );</font></div><div><font style="font-size: 16pt;">        }</font></div><div><font style="font-size: 16pt;">        return this.discoveryClient;</font></div><div><font style="font-size: 16pt;">    }</font></div></div><div style="text-align: left;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: left;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: center;"><span style="font-size: 16pt;"><img src="./index/Image [14].png" type="image/png" data-filename="Image.png"/></span></div><div style="text-align: left;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: center;"><span style="font-size: 16pt;"><img src="./index/Image [15].png" type="image/png" data-filename="Image.png"/></span></div><div style="text-align: left;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: left;"><span style="font-size: 16pt; color: rgb(255, 0, 0); font-weight: bold;">四、对比Zookeeper 和 CAP</span></div><div style="text-align: left;"></div><h6 style="box-sizing: border-box; padding: 0px; margin: 1em 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; border-radius: 20px;"><span style="font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.4;">1. 回顾CAP原则</span></span></h6><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">RDBMS (MySQL\Oracle\sqlServer) ===&gt; ACID</span></font></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">NoSQL (Redis\MongoDB) ===&gt; CAP</span></font></div></li></ul><h6 style="box-sizing: border-box; padding: 0px; margin: 1em 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; border-radius: 20px;"><span style="font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.4;">2. ACID是什么？</span></span></h6><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important; text-align: left;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;">A (Atomicity) 原子性</span></font></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important; text-align: left;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;">C (Consistency) 一致性</span></font></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important; text-align: left;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;">I (Isolation) 隔离性</span></font></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important; text-align: left;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;">D (Durability) 持久性</span></font></div></li></ul><h6 style="box-sizing: border-box; padding: 0px; margin: 1em 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; border-radius: 20px;"><span style="font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.4;">3. CAP是什么?</span></span></h6><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important; text-align: left;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;">C (Consistency) 强一致性</span></font></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important; text-align: left;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;">A (Availability) 可用性</span></font></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important; text-align: left;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;">P (Partition tolerance) 分区容错性</span></font></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">CAP的三进二：CA、AP、CP</span></font></div></li></ul><h6 style="box-sizing: border-box; padding: 0px; margin: 1em 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; border-radius: 20px;"><span style="font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.4;">4. CAP理论的核心</span></span></h6><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important; text-align: left;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">一个分布式系统不可能同时很好的满足一致性，可用性和分区容错性这三个需求</span></span></div></li></ul><div style="text-align: left;"><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 16px 0px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">根据CAP原理，将NoSQL数据库分成了满足CA原则，满足CP原则和满足AP原则三大类</span></span></div></li><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">CA：单点集群，满足一致性，可用性的系统，通常可扩展性较差</span></span></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">CP：满足一致性，分区容错的系统，通常性能不是特别高(金融业务)</span></span></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">AP：满足可用性，分区容错的系统，通常可能对一致性要求低一些</span></span></div></li></ul></ul><div><font style="font-size: 16pt;"><br/></font></div></div><div style="text-align: left;"><span style="font-size: 16pt;">推荐blog:</span><a href="https://www.cnblogs.com/incognitor/p/9759956.html" style="font-size: 16pt;">https://www.cnblogs.com/incognitor/p/9759956.html</a></div><div style="text-align: left;"><br/></div><div style="text-align: left;"><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><font style="font-size: 16pt;">Consistency 和 Availability 的矛盾</font></div><div><font style="font-size: 16pt;">一致性和可用性，为什么不可能同时成立？答案很简单，因为可能通信失败（即出现分区容错）。</font></div><div><font style="font-size: 16pt;">如果保证 G2 的一致性，那么 G1 必须在写操作时，锁定 G2 的读操作和写操作。只有数据同步后，才能重新开放读写。锁定期间，G2 不能读写，没有可用性不。</font></div><div><font style="font-size: 16pt;">如果保证 G2 的可用性，那么势必不能锁定 G2，所以一致性不成立。</font></div><div><font style="font-size: 16pt;">综上所述，G2 无法同时做到一致性和可用性。系统设计时只能选择一个目标。如果追求一致性，那么无法保证所有节点的可用性；如果追求所有节点的可用性，那就没法做到一致性。</font></div></div></div><div style="text-align: center;"><span style="font-size: 16pt;"><img src="./index/Image [16].png" type="image/png" data-filename="Image.png"/></span><span style="font-size: 16pt;"><img src="./index/Image [17].png" type="image/png" data-filename="Image.png"/></span></div><div style="text-align: left;"><span style="font-size: 16pt;"><br/></span></div><div style="text-align: left;"></div><h6 style="box-sizing: border-box; padding: 0px; margin: 1em 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; border-radius: 20px;"><span style="font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.4;">5. 作为分布式服务注册中心，Eureka比Zookeeper好在哪里？</span></span></h6><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">著名的CAP理论指出，一个分布式系统不可能同时满足C (一致性) 、A (可用性) 、P (容错性)，由于分区容错性P再分布式系统中是必须要保证的，因此我们只能再A和C之间进行权衡。</span></span></div><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important; text-align: left;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;"> Zookeeper 保证的是 CP —&gt; 满足一致性，分区容错的系统，通常性能不是特别高</span></span></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important; text-align: left;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">Eureka 保证的是 AP —&gt; 满足可用性，分区容错的系统，通常可能对一致性要求低一些</span></span></div></li></ul><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"></div><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; border-radius: 20px;"><span style="font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">Zookeeper保证的是CP</span></span></div></li><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">当向注册中心查询服务列表时，我们可以容忍注册中心返回的是几分钟以前的注册信息，但不能接收服务直接down掉不可用。也就是说，</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">服务注册功能对可用性的要求要高于一致性</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">。但zookeeper会出现这样一种情况，当master节点因为网络故障与其他节点失去联系时，剩余节点会重新进行leader选举。问题在于，选举leader的时间太长，30-120s，且选举期间整个zookeeper集群是不可用的，这就导致在选举期间注册服务瘫痪。在云部署的环境下，因为网络问题使得zookeeper集群失去master节点是较大概率发生的事件，虽然服务最终能够恢复，但是，漫长的选举时间导致注册长期不可用，是不可容忍的。</span></font></div></li></ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; border-radius: 20px;"><span style="font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">Eureka保证的是AP</span></span></div></li><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">Eureka看明白了这一点，因此在设计时就优先保证可用性。</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">Eureka各个节点都是平等的</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">，几个节点挂掉不会影响正常节点的工作，剩余的节点依然可以提供注册和查询服务。而Eureka的客户端在向某个Eureka注册时，如果发现连接失败，则会自动切换至其他节点，只要有一台Eureka还在，就能保住注册服务的可用性，只不过查到的信息可能不是最新的，除此之外，Eureka还有之中自我保护机制，如果在15分钟内超过85%的节点都没有正常的心跳，那么Eureka就认为客户端与注册中心出现了网络故障，此时会出现以下几种情况：</span></font></div></li></ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important; text-align: left;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">Eureka不在从注册列表中移除因为长时间没收到心跳而应该过期的服务</span></span></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important; text-align: left;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">Eureka仍然能够接受新服务的注册和查询请求，但是不会被同步到其他节点上 (即保证当前节点依然可用)，</span></span><span style="font-size: 16pt; color: unset; font-family: unset;">当网络稳定时，当前实例新的注册信息会被同步到其他节点中，</span><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif;">因此，Eureka可以很好的应对因网络故障导致部分节点失去联系的情况，而不会像zookeeper那样使整个注册服务瘫痪</span></div></li></ul><div style="text-align: left;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: left;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: left;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: left;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: left;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: left;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: left;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: left;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: left;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: left;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: left;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: left;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: left;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: left;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: left;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: left;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: left;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: left;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: left;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: center;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: center;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: center;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: center;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: center;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: center;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: center;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: center;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: center;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: center;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: center;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: center;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: center;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: center;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: center;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: center;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: center;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: center;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: center;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: center;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: center;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: center;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: center;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: center;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: center;"><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div></div><div><br/></div><div><br/></div><div><div><br/></div><table bgcolor="#D4DDE5" border="0" width="100%"><colgroup><col></col></colgroup><tbody><tr><td><h1>04 - SpringCloud Ribbon 学习环境搭建 ：负载均衡</h1><div><span style="font-weight: bold;">来源网址：</span> <a href="https://www.kuangstudy.com/bbs/1374942542566551554">https://www.kuangstudy.com/bbs/1374942542566551554</a></div><div><span style="font-weight: bold;">作者：</span> syra-</div></td></tr></tbody></table><div><br/></div></div><div><div><span style="font-size: 18pt;">04 - SpringCloud Ribbon 学习环境搭建 ：负载均衡 </span></div><div><font style="font-size: 16pt;"><br/></font></div><div><span style="font-size: 16pt;">springcloud-consumer-dept-80、</span><span style="font-size: 16pt;">springcloud-provider-dept-8001/2/3 </span></div><div><font style="font-size: 16pt;"><br/></font></div><h4 style="box-sizing: border-box; padding: 0px; margin: 1em 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(255, 0, 0); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Microsoft Yahei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.4;">一、理论知识</span></span></h4><h4 style="box-sizing: border-box; padding: 0px; margin: 1em 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Microsoft Yahei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.4;">1.负载均衡以及Ribbon</span></span></h4><blockquote style="box-sizing: border-box; padding: 10px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); border-left: 4px solid rgb(139, 195, 74); background: rgb(248, 248, 248); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div style="box-sizing: border-box; padding: 0px; margin: 0px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt; color: rgb(102, 102, 102); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">Ribbon是什么？</span></span></div></blockquote><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;">Spring Cloud Ribbon 是基于Netflix Ribbon 实现的一套</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-weight: bold;">客户端负载均衡的工具</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;">。</span></font></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">简单的说，Ribbon 是 Netflix 发布的开源项目，主要功能是提供客户端的软件负载均衡算法，将 Netflix 的中间层服务连接在一起。</span></span></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">Ribbon 的客户端组件提供一系列完整的配置项，如：连接超时、重试等。简单的说，就是在配置文件中列出 LoadBalancer (简称LB：负载均衡) 后面所有的及其，Ribbon 会自动的帮助你基于某种规则 (如简单轮询，随机连接等等) 去连接这些机器。我们也容易使用 Ribbon 实现自定义的负载均衡算法！</span></span></div></li></ul><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"></div><blockquote style="box-sizing: border-box; padding: 10px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); border-left: 4px solid rgb(139, 195, 74); background: rgb(248, 248, 248); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div style="box-sizing: border-box; padding: 0px; margin: 0px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt; color: rgb(102, 102, 102); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">Ribbon能干嘛？</span></span></div></blockquote><div style="text-align: center; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;; font-variant-caps: normal; font-variant-ligatures: normal;"><img src="./index/Image [18].png" type="image/png" data-filename="Image.png" width="648"/></span></font></div><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">LB，即负载均衡 (LoadBalancer) ，在微服务或分布式集群中经常用的一种应用。</span></span></font></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">负载均衡简单的说就是将用户的请求平摊的分配到多个服务上，从而达到系统的HA (高用)。</span></span></font></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">常见的负载均衡软件有 Nginx、Lvs 等等。</span></span></font></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;">Dubbo、SpringCloud 中均给我们提供了负载均衡，</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-weight: bold;">SpringCloud 的负载均衡算法可以自定义</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;">。</span></font></div></li></ul><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><ul><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 16px 0px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">负载均衡简单分类：</span></span></font></div></li></ul></ul><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><ul><ul><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 16px 0px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">集中式LB</span></span></font></div></li><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;">即在服务的提供方和消费方之间使用独立的LB设施，如</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-weight: bold;">Nginx(反向代理服务器)</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;">，由该设施负责把访问请求通过某种策略转发至服务的提供方！</span></font></div></li></ul></ul></ul></ul></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><ul><ul><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 16px 0px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">进程式 LB</span></span></font></div></li><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">将LB逻辑集成到消费方，消费方从服务注册中心获知有哪些地址可用，然后自己再从这些地址中选出一个合适的服务器。</span></span></font></div></li></ul></ul></ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-weight: bold;">Ribbon 就属于进程</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt; font-weight: bold;">式</span></span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-weight: bold;">LB</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;">，它只是一个类库，集成于消费方进程，消费方通过它来获取到服务提供方的地址！</span></font></div></li></ul></div></div><div><font style="font-size: 16pt;"><br/></font></div><div><span style="font-size: 16pt; color: rgb(255, 0, 0); font-weight: bold;">二、在Consumer中集成Ribbon，实现负载均衡</span></div><div><font style="font-size: 16pt;"><br/></font></div><div><span style="font-size: 16pt;">1.pom.xml中配置依赖</span></div><div><font style="font-size: 16pt;"><br/></font></div><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><font style="font-size: 16pt;">&lt;!--ribbon负载均衡  轮询默认--&gt;</font></div><div><font style="font-size: 16pt;">&lt;dependency&gt;</font></div><div><font style="font-size: 16pt;">    &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;</font></div><div><font style="font-size: 16pt;">    &lt;artifactId&gt;spring-cloud-starter-ribbon&lt;/artifactId&gt;</font></div><div><font style="font-size: 16pt;">    &lt;version&gt;1.4.7.RELEASE&lt;/version&gt;</font></div><div><font style="font-size: 16pt;">&lt;/dependency&gt;</font></div></div><div><font style="font-size: 16pt;"><br/></font></div><div><span style="font-size: 16pt;">2.在RestTemplate的bean上配置Ribbon ，并修改请求路径为Eureka中的应用名称，实现负载均衡</span></div><div><span style="font-size: 16pt;">Controller中的URL_PATH:</span></div><div><br/></div><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><font style="font-size: 16pt;">//Ribbon:我们这里的地址，应该是一个变量，通过服务名来访问</font></div><div><font style="font-size: 16pt;">//private static final String REST_URL_PREFIX = &quot;http://localhost:8001&quot;;</font></div><div><font style="font-size: 16pt;">private static final String REST_URL_PREFIX = &quot;http://SPRINGCLOUD-PROVIDER-DEPT&quot;;</font></div></div><div><br/></div><div><span style="font-size: 16pt;">Bean配置:</span></div><div><br/></div><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><span style="font-size: 16pt;">import com.netflix.loadbalancer.*;</span></div><div><font style="font-size: 16pt;">import org.springframework.cloud.client.loadbalancer.LoadBalanced;</font></div><div><font style="font-size: 16pt;">import org.springframework.context.annotation.Bean;</font></div><div><font style="font-size: 16pt;">import org.springframework.context.annotation.Configuration;</font></div><div><font style="font-size: 16pt;">import org.springframework.web.client.RestTemplate;</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">@Configuration</font></div><div><font style="font-size: 16pt;">public class ConfigBean {</font></div><div><font style="font-size: 16pt;">    @Bean</font></div><div><font style="font-size: 16pt;">    @LoadBalanced //Ribbon 实现负载均衡</font></div><div><font style="font-size: 16pt;">    public RestTemplate getRestemplate() {</font></div><div><font style="font-size: 16pt;">        return new RestTemplate();</font></div><div><font style="font-size: 16pt;">    }</font></div><div><font style="font-size: 16pt;">}</font></div></div><div><font style="font-size: 16pt;"><br/></font></div><div><span style="font-size: 16pt;">3.主启动类</span></div><div><font style="font-size: 16pt;"><br/></font></div><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><font style="font-size: 16pt;">@SpringBootApplication</font></div><div><font style="font-size: 16pt;">@EnableEurekaClient</font></div><div><font style="font-size: 16pt;">@RibbonClient(name = &quot;SPRINGCLOUD-PROVIDER-DEPT&quot; , configuration = MyRule.class) //配置路由规则；  默认是轮询  仅仅需要在restTemplate上添加LoadBalanced</font></div><div><font style="font-size: 16pt;">public class ApplicationConsumer {</font></div><div><font style="font-size: 16pt;">    public static void main(String[] args) {</font></div><div><font style="font-size: 16pt;">        SpringApplication.run(ApplicationConsumer.class ,args);</font></div><div><font style="font-size: 16pt;">    }</font></div><div><font style="font-size: 16pt;">}</font></div></div><div><font style="font-size: 16pt;"><br/></font></div><div><span style="font-size: 16pt;">4.流程图</span></div><div style="text-align: center;"><span style="font-size: 16pt;"><img src="./index/Image [19].png" type="image/png" data-filename="Image.png" width="999"/></span></div><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">新建两个服务提供者Moudle：springcloud-provider-dept-8003、springcloud-provider-dept-8002</span></span></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">参照springcloud-provider-dept-8001 依次为另外两个Moudle添加pom.xml依赖 、resourece下的mybatis和application.yml配置，Java代码</span></span></div></li><li><div style="text-align: left;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">启动所有服务测试(根据自身电脑配置决定启动服务的个数)，访问</span><a href="http://eureka7001.com:7002/%E6%9F%A5%E7%9C%8B%E7%BB%93%E6%9E%9C" style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background: transparent; font-size: 16pt; color: rgb(65, 131, 196); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">http://eureka7001.com:7002/ 查看结果</a></font></div></li></ul><div style="text-align: center;"><br/></div><div><font style="font-size: 16pt;"><br/></font></div><div><span style="font-size: 16pt;">访问</span><span style="font-size: 16pt;"><a href="http://127.0.0.1/consumer/dept/findAll" style="font-size: 16pt;">http://127.0.0.1/consumer/dept/findAll</a></span><span style="font-size: 16pt;">，结果显示从不同db中轮询查询结果（可以自定义IRule的规则，需要手动进行绑定，在启动类上，且自定义的IRule不能在扫描路径下）</span></div><div style="text-align: center;"><span style="font-size: 16pt;"><img src="./index/Image [20].png" type="image/png" data-filename="Image.png" width="551"/></span><span style="font-size: 16pt;"><img src="./index/Image [21].png" type="image/png" data-filename="Image.png" width="430"/></span></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">以上这种</span><span style="box-sizing: border-box; border-radius: 20px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">每次访问</span><a href="http://127.0.0.1/consumer/dept/findAll" style="font-size: 16pt; font-family: &quot;Microsoft YaHei&quot;; font-weight: bold;">http://127.0.0.1/consumer/dept/findAll</a><span style="font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;; font-weight: bold;">随机访问集群中某个服务提供者，这种情况叫做轮询</span><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">，轮询算法在SpringCloud中可以自定义。</span></font></div><div><font style="font-size: 16pt;"><br/></font></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; border-radius: 20px;"><span style="font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">如何切换或者自定义规则呢？</span></span></div><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">在bean中配置Rule方式</span></div></li></ul><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><font><span style="color: rgb(24, 24, 24);"><font style="font-size: 16pt;">    /**</font></span></font></div><div><font><span style="color: rgb(24, 24, 24);"><font style="font-size: 16pt;">     * IRule:</font></span></font></div><div><font><span style="color: rgb(24, 24, 24);"><font style="font-size: 16pt;">     * RoundRobinRule 轮询策略</font></span></font></div><div><font><span style="color: rgb(24, 24, 24);"><font style="font-size: 16pt;">     * RandomRule 随机策略</font></span></font></div><div><font><span style="color: rgb(24, 24, 24);"><font style="font-size: 16pt;">     * AvailabilityFilteringRule ： 会先过滤掉，跳闸，访问故障的服务~，对剩下的进行轮询~</font></span></font></div><div><font><span style="color: rgb(24, 24, 24);"><font style="font-size: 16pt;">     * RetryRule ： 会先按照轮询获取服务~，如果服务获取失败，则会在指定的时间内进行，重试</font></span></font></div><div><font><span style="color: rgb(24, 24, 24);"><font style="font-size: 16pt;">     */</font></span></font></div><div><font><span style="color: rgb(24, 24, 24);"><font style="font-size: 16pt;">    @Bean</font></span></font></div><div><font><span style="color: rgb(24, 24, 24);"><font style="font-size: 16pt;">    public IRule myRule() {</font></span></font></div><div><font><span style="color: rgb(24, 24, 24);"><font style="font-size: 16pt;">        return new RandomRule();//使用随机策略</font></span></font></div><div><font><span style="color: rgb(24, 24, 24);"><font style="font-size: 16pt;">        //return new RoundRobinRule();//使用轮询策略</font></span></font></div><div><font><span style="color: rgb(24, 24, 24);"><font style="font-size: 16pt;">        //return new AvailabilityFilteringRule();//使用轮询策略</font></span></font></div><div><font><span style="color: rgb(24, 24, 24);"><font style="font-size: 16pt;">        //return new RetryRule();//使用轮询策略</font></span></font></div><div><font><span style="color: rgb(24, 24, 24);"><font style="font-size: 16pt;">    }</font></span></font></div></div><div><br/></div></div><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">在主启动类绑定Rule</span></font></div></li></ul><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><font style="font-size: 16pt;">//在微服务启动的时候就能加载自定义的Ribbon类(自定义的规则会覆盖原有默认的规则)</font></div><div><font style="font-size: 16pt;">@RibbonClient(name = &quot;SPRINGCLOUD-PROVIDER-DEPT&quot;,configuration = MyRule.class)//开启负载均衡,并指定自定义的规则</font></div></div><div><br/></div></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"></div><ul><li><div><span style="font-size: 16pt;">自定义Rule，模仿轮询RoundRobinRule</span></div></li></ul><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><font style="font-size: 16pt;">package cn.edu.rule;//注意路径 没有在扫描路径下</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">import com.netflix.client.config.IClientConfig;</font></div><div><font style="font-size: 16pt;">import com.netflix.loadbalancer.AbstractLoadBalancerRule;</font></div><div><font style="font-size: 16pt;">import com.netflix.loadbalancer.ILoadBalancer;</font></div><div><font style="font-size: 16pt;">import com.netflix.loadbalancer.Server;</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">import java.util.List;</font></div><div><font style="font-size: 16pt;">import java.util.concurrent.ThreadLocalRandom;</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">public class CountRule extends AbstractLoadBalancerRule {</font></div><div><font style="font-size: 16pt;">    /**</font></div><div><font style="font-size: 16pt;">     * 每个服务访问5次则换下一个服务(总共3个服务)</font></div><div><font style="font-size: 16pt;">     *</font></div><div><font style="font-size: 16pt;">     * total=0,默认=0,如果=5,指向下一个服务节点</font></div><div><font style="font-size: 16pt;">     * index=0,默认=0,如果total=5,index+1</font></div><div><font style="font-size: 16pt;">     */</font></div><div><font style="font-size: 16pt;">    private int total = 0;//被调用的次数</font></div><div><font style="font-size: 16pt;">    private int currentIndex = 0;//当前是谁在提供服务</font></div><div><font style="font-size: 16pt;">    //@edu.umd.cs.findbugs.annotations.SuppressWarnings(value = &quot;RCN_REDUNDANT_NULLCHECK_OF_NULL_VALUE&quot;)</font></div><div><font style="font-size: 16pt;">    public Server choose(ILoadBalancer lb, Object key) {</font></div><div><font style="font-size: 16pt;">        if (lb == null) {</font></div><div><font style="font-size: 16pt;">            return null;</font></div><div><font style="font-size: 16pt;">        }</font></div><div><font style="font-size: 16pt;">        Server server = null;</font></div><div><font style="font-size: 16pt;">        while (server == null) {</font></div><div><font style="font-size: 16pt;">            if (Thread.interrupted()) {</font></div><div><font style="font-size: 16pt;">                return null;</font></div><div><font style="font-size: 16pt;">            }</font></div><div><font style="font-size: 16pt;">            List&lt;Server&gt; upList = lb.getReachableServers();//获得当前活着的服务</font></div><div><font style="font-size: 16pt;">            List&lt;Server&gt; allList = lb.getAllServers();//获取所有的服务</font></div><div><font style="font-size: 16pt;">            int serverCount = allList.size();</font></div><div><font style="font-size: 16pt;">            if (serverCount == 0) {</font></div><div><font style="font-size: 16pt;">                /*</font></div><div><font style="font-size: 16pt;">                 * No servers. End regardless of pass, because subsequent passes</font></div><div><font style="font-size: 16pt;">                 * only get more restrictive.</font></div><div><font style="font-size: 16pt;">                 */</font></div><div><font style="font-size: 16pt;">                return null;</font></div><div><font style="font-size: 16pt;">            }</font></div><div><font style="font-size: 16pt;">            //int index = chooseRandomInt(serverCount);//生成区间随机数</font></div><div><font style="font-size: 16pt;">            //server = upList.get(index);//从或活着的服务中,随机获取一个</font></div><div><font style="font-size: 16pt;">            //=====================自定义代码=========================</font></div><div><font style="font-size: 16pt;">            if (total &lt; 5) {</font></div><div><font style="font-size: 16pt;">                server = upList.get(currentIndex);</font></div><div><font style="font-size: 16pt;">                total++;</font></div><div><font style="font-size: 16pt;">            } else {</font></div><div><font style="font-size: 16pt;">                total = 0;</font></div><div><font style="font-size: 16pt;">                currentIndex++;</font></div><div><font style="font-size: 16pt;">                if (currentIndex &gt;= upList.size()) {</font></div><div><font style="font-size: 16pt;">                    currentIndex = 0;</font></div><div><font style="font-size: 16pt;">                }</font></div><div><font style="font-size: 16pt;">                server = upList.get(currentIndex);//从活着的服务中,获取指定的服务来进行操作</font></div><div><font style="font-size: 16pt;">            }</font></div><div><font style="font-size: 16pt;">            //======================================================</font></div><div><font style="font-size: 16pt;">            if (server == null) {</font></div><div><font style="font-size: 16pt;">                /*</font></div><div><font style="font-size: 16pt;">                 * The only time this should happen is if the server list were</font></div><div><font style="font-size: 16pt;">                 * somehow trimmed. This is a transient condition. Retry after</font></div><div><font style="font-size: 16pt;">                 * yielding.</font></div><div><font style="font-size: 16pt;">                 */</font></div><div><font style="font-size: 16pt;">                Thread.yield();</font></div><div><font style="font-size: 16pt;">                continue;</font></div><div><font style="font-size: 16pt;">            }</font></div><div><font style="font-size: 16pt;">            if (server.isAlive()) {</font></div><div><font style="font-size: 16pt;">                return (server);</font></div><div><font style="font-size: 16pt;">            }</font></div><div><font style="font-size: 16pt;">            // Shouldn't actually happen.. but must be transient or a bug.</font></div><div><font style="font-size: 16pt;">            server = null;</font></div><div><font style="font-size: 16pt;">            Thread.yield();</font></div><div><font style="font-size: 16pt;">        }</font></div><div><font style="font-size: 16pt;">        return server;</font></div><div><font style="font-size: 16pt;">    }</font></div><div><font style="font-size: 16pt;">    protected int chooseRandomInt(int serverCount) {</font></div><div><font style="font-size: 16pt;">        return ThreadLocalRandom.current().nextInt(serverCount);</font></div><div><font style="font-size: 16pt;">    }</font></div><div><font style="font-size: 16pt;">    @Override</font></div><div><font style="font-size: 16pt;">    public Server choose(Object key) {</font></div><div><font style="font-size: 16pt;">        return choose(getLoadBalancer(), key);</font></div><div><font style="font-size: 16pt;">    }</font></div><div><font style="font-size: 16pt;">    @Override</font></div><div><font style="font-size: 16pt;">    public void initWithNiwsConfig(IClientConfig clientConfig) {</font></div><div><font style="font-size: 16pt;">        // TODO Auto-generated method stub</font></div><div><font style="font-size: 16pt;">    }</font></div><div><font style="font-size: 16pt;">}</font></div></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><span style="font-size: 18pt;"><br/></span></div></div><div><br/></div><div><br/></div><div><div><br/></div><table bgcolor="#D4DDE5" border="0" width="100%"><colgroup><col></col></colgroup><tbody><tr><td><h1>05 - SpringCloud Feign 学习环境搭建 ：负载均衡 （ 面向接口编程方式实现 ）</h1><div><span style="font-weight: bold;">来源网址：</span> <a href="https://www.kuangstudy.com/bbs/1374942542566551554">https://www.kuangstudy.com/bbs/1374942542566551554</a></div><div><span style="font-weight: bold;">作者：</span> syra-</div></td></tr></tbody></table><div><br/></div></div><div><div><span style="font-size: 18pt;">05 - SpringCloud Feign 学习环境搭建 ：负载均衡 （  面向接口编程方式实现 ） </span></div><div><span style="font-size: 18pt;"><br/></span></div><div><span style="font-size: 18pt;">Springcloud-consumer-dept-feign-80</span></div><div><span style="font-size: 18pt;"><br/></span></div><div><font color="#FF0000" style="font-size: 16pt;"><span style="font-size: 16pt; color: rgb(255, 0, 0); font-weight: bold;">一、理论知识</span></font></div><div><font color="#FF0000" style="font-size: 16pt;"><br/></font></div><h4 style="box-sizing: border-box; padding: 0px; margin: 1em 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Microsoft Yahei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.4;">1.Feign简介</span></span></h4><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">Feign是声明式Web Service客户端，它让微服务之间的调用变得更简单，类似controller调用service。SpringCloud集成了Ribbon和Eureka，可以使用Feigin提供负载均衡的http客户端</span></span></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; border-radius: 20px;"><span style="font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">只需要创建一个接口，然后添加注解即可~</span></span></div></li><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">Feign，主要是社区版，大家都习惯面向接口编程。这个是很多开发人员的规范。调用微服务访问两种方法</span></span></div></li><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; list-style: decimal-leading-zero; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">微服务名字 【ribbon】</span></span></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; list-style: decimal-leading-zero; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">接口和注解 【feign】</span></span></div></li></ul></ul></ul><div style="box-sizing: border-box; padding: 0px; margin: 0px; list-style: decimal-leading-zero; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; border-radius: 20px;"><span style="font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">2.Feign能干什么？</span></span></div><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">Feign旨在使编写Java Http客户端变得更容易</span></span></div></li><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;">前面在使用</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-weight: bold;">Ribbon</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;"> </span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;">+</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;"> </span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-weight: bold;">RestTemplate</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;">时，利用</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-weight: bold;">RestTemplate</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;">对Http请求的封装处理，形成了一套模板化的调用方法。但是在实际开发中，由于对服务依赖的调用可能不止一处，往往一个接口会被多处调用，所以通常都会针对每个微服务自行封装一个客户端类来包装这些依赖服务的调用。所以，</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-weight: bold;">Feign</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;">在此基础上做了进一步的封装，由他来帮助我们定义和实现依赖服务接口的定义，在Feign的实现下，我们只需要创建一个接口并使用注解的方式来配置它 (类似以前Dao接口上标注Mapper注解，现在是一个微服务接口上面标注一个Feign注解)，即可完成对服务提供方的接口绑定，简化了使用Spring Cloud Ribbon 时，自动封装服务调用客户端的开发量。</span></font></div></li></ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; border-radius: 20px;"><span style="font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">Feign默认集成了Ribbon</span></span></div></li><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;">利用</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-weight: bold;">Ribbon</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;">维护了MicroServiceCloud-Dept的服务列表信息，并且通过轮询实现了客户端的负载均衡，而与</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-weight: bold;">Ribbon</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;">不同的是，通过</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-weight: bold;">Feign</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;">只需要定义服务绑定接口且以声明式的方法，优雅而简单的实现了服务调用。</span></font></div></li></ul></ul><div><span style="font-size: 18pt;"><br/></span></div><div><font style="font-size: 16pt;"><span style="font-size: 16pt; color: rgb(255, 0, 0); font-weight: bold;">二、Feign - Consumer搭建</span></font></div><div style="box-sizing: border-box; padding: 0px; margin: 0px; list-style: decimal-leading-zero; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 16px 0px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">创建springcloud-consumer-fdept-feign模块</span></span></div></li></ul><div><span style="font-size: 16pt;">1.pom.xml导入feign依赖</span></div><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><font style="font-size: 16pt;">&lt;!--ribbon负载均衡  轮询默认，对Ribbon的进一步封装--&gt;</font></div><div><font style="font-size: 16pt;">&lt;dependency&gt;</font></div><div><font style="font-size: 16pt;">    &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;</font></div><div><font style="font-size: 16pt;">    &lt;artifactId&gt;spring-cloud-starter-ribbon&lt;/artifactId&gt;</font></div><div><font style="font-size: 16pt;">    &lt;version&gt;1.4.7.RELEASE&lt;/version&gt;</font></div><div><font style="font-size: 16pt;">&lt;/dependency&gt;</font></div></div></div><div><span style="font-size: 18pt;"><br/></span></div><div><span style="font-size: 18pt;">2.在springcloud-api下新建feign的接口</span></div><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><font style="font-size: 16pt;">package cn.edu.zzu.service;</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">import cn.edu.zzu.domain.Dept;</font></div><div><font style="font-size: 16pt;">import org.springframework.cloud.openfeign.FeignClient;</font></div><div><font style="font-size: 16pt;">import org.springframework.stereotype.Component;</font></div><div><font style="font-size: 16pt;">import org.springframework.web.bind.annotation.GetMapping;</font></div><div><font style="font-size: 16pt;">import org.springframework.web.bind.annotation.PathVariable;</font></div><div><font style="font-size: 16pt;">import org.springframework.web.bind.annotation.PostMapping;</font></div><div><font style="font-size: 16pt;">import org.springframework.web.bind.annotation.RequestMapping;</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">import java.util.List;</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">/**</font></div><div><font style="font-size: 16pt;">* 负载均衡 feign</font></div><div><font style="font-size: 16pt;">* 请求访问服务提供者的接口信息,请求路径要保持和provider的controller中的path一致才可以</font></div><div><font style="font-size: 16pt;">*/</font></div><div><font style="font-size: 16pt;">@Component</font></div><div><font style="font-size: 16pt;">@FeignClient(value = &quot;SPRINGCLOUD-PROVIDER-DEPT&quot;) </font></div><div><font style="font-size: 16pt;">@RequestMapping(&quot;/dept&quot;)</font></div><div><font style="font-size: 16pt;">public interface IDeptClientService {</font></div><div><font style="font-size: 16pt;">    /**</font></div><div><font style="font-size: 16pt;">     * 添加部门</font></div><div><font style="font-size: 16pt;">     * @param dept</font></div><div><font style="font-size: 16pt;">     * @return</font></div><div><font style="font-size: 16pt;">     */</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">    @PostMapping(&quot;/addDept&quot;)</font></div><div><font style="font-size: 16pt;">    boolean addDept(Dept dept);</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">    /**</font></div><div><font style="font-size: 16pt;">     * 根据id查询</font></div><div><font style="font-size: 16pt;">     * @param id</font></div><div><font style="font-size: 16pt;">     * @return</font></div><div><font style="font-size: 16pt;">     */</font></div><div><font style="font-size: 16pt;">    @GetMapping(&quot;/get/{id}&quot;)</font></div><div><font style="font-size: 16pt;">    Dept findDeptById(@PathVariable(&quot;id&quot;) Long id);</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">    /**</font></div><div><font style="font-size: 16pt;">     * 查询所有</font></div><div><font style="font-size: 16pt;">     * @return</font></div><div><font style="font-size: 16pt;">     */</font></div><div><font style="font-size: 16pt;">    @GetMapping(&quot;/getAll&quot;)</font></div><div><font style="font-size: 16pt;">    List&lt;Dept&gt; findAll();</font></div><div><font style="font-size: 16pt;">}</font></div></div><div><span style="font-size: 18pt;"><br/></span></div><div><span style="font-size: 18pt;">3.修改springcloud-consumer-dept-feign-80的DeptController的请求方式</span></div><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><font style="font-size: 16pt;">package cn.edu.zzu.controller;</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">import cn.edu.zzu.domain.Dept;</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">import cn.edu.zzu.service.IDeptClientService;</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">import org.springframework.beans.factory.annotation.Autowired;</font></div><div><font style="font-size: 16pt;">import org.springframework.web.bind.annotation.*;</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">import java.util.List;</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">@RestController</font></div><div><font style="font-size: 16pt;">@RequestMapping(&quot;/consumer/dept&quot;)</font></div><div><font style="font-size: 16pt;">public class Deptcontroller {</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">    @Autowired</font></div><div><font style="font-size: 16pt;">    IDeptClientService iDeptClientService;</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">    @GetMapping(&quot;/get/{id}&quot;)</font></div><div><font style="font-size: 16pt;">    public Dept findDeptById(@PathVariable(&quot;id&quot;) Long id){</font></div><div><font style="font-size: 16pt;">        System.out.println(id+&quot;====================&quot;);</font></div><div><font style="font-size: 16pt;">        return iDeptClientService.findDeptById(id);</font></div><div><font style="font-size: 16pt;">    }</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">    @PostMapping(&quot;/addDept&quot;)</font></div><div><font style="font-size: 16pt;">    public boolean addDept(Dept dept){</font></div><div><font style="font-size: 16pt;">        return iDeptClientService.addDept(dept);</font></div><div><font style="font-size: 16pt;">    }</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">    @GetMapping(&quot;/findAll&quot;)</font></div><div><font style="font-size: 16pt;">    public List&lt;Dept&gt; findAll(){</font></div><div><font style="font-size: 16pt;">        System.out.println(&quot;++++++++++++++++++++++++++++++alll ++++++++++++++++++&quot;);</font></div><div><font style="font-size: 16pt;">        return iDeptClientService.findAll();</font></div><div><font style="font-size: 16pt;">    }</font></div><div><font style="font-size: 16pt;">}</font></div></div><div><span style="font-size: 18pt;"><br/></span></div><div><span style="font-size: 18pt;">4.主启动类</span></div><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><font style="font-size: 16pt;">package cn.edu.zzu;</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">import org.springframework.boot.SpringApplication;</font></div><div><font style="font-size: 16pt;">import org.springframework.boot.autoconfigure.SpringBootApplication;</font></div><div><font style="font-size: 16pt;">import org.springframework.cloud.netflix.eureka.EnableEurekaClient;</font></div><div><font style="font-size: 16pt;">import org.springframework.cloud.openfeign.EnableFeignClients;</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">@SpringBootApplication</font></div><div><font style="font-size: 16pt;">@EnableEurekaClient</font></div><div><font style="font-size: 16pt;">@EnableFeignClients(basePackages ={&quot;cn.edu.zzu&quot;})</font></div><div><font style="font-size: 16pt;">public class ApplicationConsumer_Feign {</font></div><div><font style="font-size: 16pt;">    public static void main(String[] args) {</font></div><div><font style="font-size: 16pt;">        SpringApplication.run(ApplicationConsumer_Feign.class ,args);</font></div><div><font style="font-size: 16pt;">    }</font></div><div><font style="font-size: 16pt;">}</font></div></div><div><span style="font-size: 18pt;"><br/></span></div><h4 style="box-sizing: border-box; padding: 0px; margin: 1em 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(255, 0, 0); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Microsoft Yahei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.4;"> 三、</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(255, 0, 0); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Microsoft Yahei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.4;">Feign和Ribbon</span></font></h4><h4 style="box-sizing: border-box; padding: 0px; margin: 1em 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Microsoft Yahei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.4;">Feign和Ribbon如何选择？</span></span></h4><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; border-radius: 20px;"><span style="font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">根据个人习惯而定，如果喜欢REST风格使用Ribbon；如果喜欢社区版的面向接口风格使用Feign.</span></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">Feign 本质上也是实现了 Ribbon，只不过后者是在调用方式上，为了满足一些开发者习惯的接口调用习惯！</span></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">下面我们关闭springcloud-consumer-dept-80 这个服务消费方，换用springcloud-consumer-dept-feign(端口还是80) 来代替：(依然可以正常访问，就是调用方式相比于Ribbon变化了)</span></span></div><div><span style="font-size: 18pt;"><br/></span></div><div><span style="font-size: 18pt;"><br/></span></div><div><span style="font-size: 18pt;"><br/></span></div><div><span style="font-size: 18pt;"><br/></span></div><div><span style="font-size: 18pt;"><br/></span></div><div><span style="font-size: 18pt;"><br/></span></div><div><span style="font-size: 18pt;"><br/></span></div><div><span style="font-size: 18pt;"><br/></span></div><div><span style="font-size: 18pt;"><br/></span></div><div><span style="font-size: 18pt;"><br/></span></div><div><span style="font-size: 18pt;"><br/></span></div><div><span style="font-size: 18pt;"><br/></span></div><div><span style="font-size: 18pt;"><br/></span></div><div><span style="font-size: 18pt;"><br/></span></div><div><span style="font-size: 18pt;"><br/></span></div><div><span style="font-size: 18pt;"><br/></span></div><div><span style="font-size: 18pt;"><br/></span></div><div><span style="font-size: 18pt;"><br/></span></div><div><span style="font-size: 18pt;"><br/></span></div><div><span style="font-size: 18pt;"><br/></span></div><div><span style="font-size: 18pt;"><br/></span></div><div><span style="font-size: 18pt;"><br/></span></div><div><span style="font-size: 18pt;"><br/></span></div><div><span style="font-size: 18pt;"><br/></span></div><div><span style="font-size: 18pt;"><br/></span></div><div><span style="font-size: 18pt;"><br/></span></div><div><span style="font-size: 18pt;"><br/></span></div></div><div><br/></div><div><br/></div><div><div><br/></div><table bgcolor="#D4DDE5" border="0" width="100%"><colgroup><col></col></colgroup><tbody><tr><td><h1>06 - SpringCloud Hystrix 学习环境搭建 ：服务熔断、服务降级、监控面板dashboard</h1><div><span style="font-weight: bold;">来源网址：</span> <a href="https://www.kuangstudy.com/bbs/1374942542566551554">https://www.kuangstudy.com/bbs/1374942542566551554</a></div><div><span style="font-weight: bold;">作者：</span> syra-</div></td></tr></tbody></table><div><br/></div></div><div><div><div><span style="font-size: 18pt;">06 - SpringCloud Hystrix 学习环境搭建 ：服务熔断、服务降级、监控面板dashboard </span></div><div><font style="font-size: 16pt;"><br/></font></div><div><span style="font-size: 16pt;">springcloud-provider-dept-hystrix、springcloud-consumer-dept-hystrix-dashboard、springcloud-api</span></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><span style="font-size: 16pt; color: rgb(255, 0, 0); font-weight: bold;">一、理论知识</span></font></div><blockquote style="box-sizing: border-box; padding: 10px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); border-left: 4px solid rgb(139, 195, 74); background: rgb(248, 248, 248); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div style="box-sizing: border-box; padding: 0px; margin: 0px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt; color: rgb(102, 102, 102); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">分布式系统面临的问题</span></span></div></blockquote><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">复杂分布式体系结构中的应用程序有数十个依赖关系，每个依赖关系在某些时候将不可避免失败！</span></span></div></li></ul><h4 style="box-sizing: border-box; padding: 0px; margin: 1em 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Microsoft Yahei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.4;">1.服务雪崩</span></span></h4><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">多个微服务之间调用的时候，假设微服务A调用微服务B和微服务C，微服务B和微服务C又调用其他的微服务，这就是所谓的“扇出”，如果扇出的链路上</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">某个微服务的调用响应时间过长，或者不可用</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">，对微服务A的调用就会占用越来越多的系统资源，进而引起系统崩溃，所谓的“雪崩效应”。</span></font></div></li></ul><div style="text-align: center; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;; font-variant-caps: normal; font-variant-ligatures: normal;"><img src="./index/Image [22].png" type="image/png" data-filename="Image.png"/></span></div><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">对于高流量的应用来说，单一的后端依赖可能会导致所有服务器上的所有资源都在几十秒内饱和。比失败更糟糕的是，这些应用程序还可能导致服务之间的延迟增加，备份队列，线程和其他系统资源紧张，导致整个系统发生更多的级联故障，</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">这些都表示需要对故障和延迟进行隔离和管理，以达到单个依赖关系的失败而不影响整个应用程序或系统运行</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">。</span></font></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">我们需要，</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">弃车保帅</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">！</span></font></div></li></ul><h4 style="box-sizing: border-box; padding: 0px; margin: 1em 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Microsoft Yahei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.4;">2 什么是Hystrix？</span></span></h4><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">Hystrix</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">是一个应用于处理分布式系统的延迟和容错的开源库，在分布式系统里，许多依赖不可避免的会调用失败，比如超时，异常等，</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">Hystrix</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"> </span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">能够保证在一个依赖出问题的情况下，不会导致整个体系服务失败，避免级联故障，以提高分布式系统的弹性。</span></font></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">“</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">断路器</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">”本身是一种开关装置，当某个服务单元发生故障之后，通过断路器的故障监控 (类似熔断保险丝) ，</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">向调用方返回一个服务预期的，可处理的备选响应 (FallBack) ，而不是长时间的等待或者抛出调用方法无法处理的异常，这样就可以保证了服务调用方的线程不会被长时间，不必要的占用</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">，从而避免了故障在分布式系统中的蔓延，乃至雪崩。</span></font></div></li></ul><div style="text-align: center; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;; font-variant-caps: normal; font-variant-ligatures: normal;"><img src="./index/Image [23].png" type="image/png" data-filename="Image.png"/></span></div><h4 style="box-sizing: border-box; padding: 0px; margin: 1em 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Microsoft Yahei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.4;">3 Hystrix能干嘛？</span></span></h4><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">服务降级</span></span></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">服务熔断</span></span></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">服务限流</span></span></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">接近实时的监控</span></span></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">…</span></span></div></li></ul><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">当一切正常时，请求流可以如下所示：</span></span></div><div style="text-align: center; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;; font-variant-caps: normal; font-variant-ligatures: normal;"><img src="./index/Image [24].png" type="image/png" data-filename="Image.png"/></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">当许多后端系统中有一个潜在阻塞服务时，它可以阻止整个用户请求：</span></span></div><div style="text-align: center; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;; font-variant-caps: normal; font-variant-ligatures: normal;"><img src="./index/Image [25].png" type="image/png" data-filename="Image.png"/></span></div><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">随着大容量通信量的增加，单个后端依赖项的潜在性会导致所有服务器上的所有资源在几秒钟内饱和。</span></span></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">应用程序中通过网络或客户端库可能导致网络请求的每个点都是潜在故障的来源。比失败更糟糕的是，这些应用程序还可能导致服务之间的延迟增加，从而备份队列、线程和其他系统资源，从而导致更多跨系统的级联故障。</span></span></div></li></ul><div style="text-align: center; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;; font-variant-caps: normal; font-variant-ligatures: normal;"><img src="./index/Image [26].png" type="image/png" data-filename="Image.png"/></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">当使用</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">Hystrix</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">包装每个基础依赖项时，上面的图表中所示的体系结构会发生类似于以下关系图的变化。</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">每个依赖项是相互隔离的</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">，限制在延迟发生时它可以填充的资源中，并包含在回退逻辑中，该逻辑决定在依赖项中发生任何类型的故障时要做出什么样的响应：</span></font></div><div style="text-align: center; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;; font-variant-caps: normal; font-variant-ligatures: normal;"><img src="./index/Image [27].png" type="image/png" data-filename="Image.png"/></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">官网资料</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">：</span><a href="https://github.com/Netflix/Hystrix/wiki" style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background: transparent; font-size: 16pt; color: rgb(65, 131, 196); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">https://github.com/Netflix/Hystrix/wiki</a></font></div><h4 style="box-sizing: border-box; padding: 0px; margin: 1em 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Microsoft Yahei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.4;">4 服务熔断</span></span></h4><ul><li><div><h5 style="box-sizing: border-box; padding: 0px; margin: 1em 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.4;">什么是服务熔断?</span></span></h5></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">熔断机制是赌赢雪崩效应的一种微服务链路保护机制</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">。</span></font></div></li><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">当扇出链路的某个微服务不可用或者响应时间太长时，会进行服务的降级，</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">进而熔断该节点微服务的调用，快速返回错误的响应信息</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">。检测到该节点微服务调用响应正常后恢复调用链路。在SpringCloud框架里熔断机制通过Hystrix实现。Hystrix会监控微服务间调用的状况，当失败的调用到一定阀值缺省是</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">5秒内20次调用失败，就会启动熔断机制</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">。</span></font></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">熔断机制的注解是：</span><a href="https://github.com/HystrixCommand" style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; overflow-wrap: break-word; background: transparent; border-radius: 3px; border: 1px solid rgb(238, 238, 238); font-size: 16pt; color: rgb(65, 131, 196); font-family: &quot;YaHei Consolas Hybrid&quot;, Consolas, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Helvetica, monospace, monospace; font-variant-caps: normal; font-variant-ligatures: normal;" title="@HystrixCommand">@HystrixCommand</a><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">。</span></font></div></li></ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">服务熔断解决如下问题：</span></span></div></li><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">当所依赖的对象不稳定时，能够起到快速失败的目的；</span></span></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">快速失败后，能够根据一定的算法动态试探所依赖对象是否恢复。</span></span></div></li></ul></ul><h5 style="box-sizing: border-box; padding: 0px; margin: 1em 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(255, 0, 0); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.4;">二、入门案例 | </span></span><span style="font-size: 16pt; box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(255, 0, 0); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.4;">新建springcloud-provider-dept-hystrix-8001模块  服务熔断</span></h5><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">1.pom.xml依赖</span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><font style="font-size: 16pt;">&lt;!--导入Hystrix依赖--&gt;</font></div><div><font style="font-size: 16pt;">&lt;dependency&gt;</font></div><div><font style="font-size: 16pt;">    &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;</font></div><div><font style="font-size: 16pt;">    &lt;artifactId&gt;spring-cloud-starter-hystrix&lt;/artifactId&gt;</font></div><div><font style="font-size: 16pt;">    &lt;version&gt;1.4.7.RELEASE&lt;/version&gt;</font></div><div><font style="font-size: 16pt;">&lt;/dependency&gt;</font></div></div><div><br/></div></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">2.在DeptController中配置Hystrix服务熔断方法</span></div><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><font style="font-size: 16pt;">package cn.edu.zzu.controller;</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">import cn.edu.zzu.domain.Dept;</font></div><div><font style="font-size: 16pt;">import cn.edu.zzu.serrvice.IDeptService;</font></div><div><font style="font-size: 16pt;">import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;</font></div><div><font style="font-size: 16pt;">import org.springframework.beans.factory.annotation.Autowired;</font></div><div><font style="font-size: 16pt;">import org.springframework.web.bind.annotation.*;</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">@RestController</font></div><div><font style="font-size: 16pt;">@RequestMapping(&quot;/dept&quot;)</font></div><div><font style="font-size: 16pt;">public class DeptController {</font></div><div><font style="font-size: 16pt;">    @Autowired</font></div><div><font style="font-size: 16pt;">    private IDeptService iDeptService;</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">    @GetMapping(&quot;/get/{id}&quot;)</font></div><div><font style="font-size: 16pt;">    @HystrixCommand(fallbackMethod = &quot;hystrixGet&quot;)  //方法服务熔断</font></div><div><font style="font-size: 16pt;">    public Dept getDeptById(@PathVariable(&quot;id&quot;) Long id) {</font></div><div><font style="font-size: 16pt;">        Dept deptById = iDeptService.findDeptById(id);</font></div><div><font style="font-size: 16pt;">        if (deptById == null) {</font></div><div><font style="font-size: 16pt;">            throw new RuntimeException(&quot;id==&gt;&quot;+id+&quot;不存在该用户，或者信息无法找到~&quot;);</font></div><div><font style="font-size: 16pt;">        }</font></div><div><font style="font-size: 16pt;">        return deptById;</font></div><div><font style="font-size: 16pt;">    }</font></div><div><font style="font-size: 16pt;">    /**</font></div><div><font><span style="font-size: 16pt;">   </span> <font style="font-size: 16pt;">*</font></font><font style="font-size: 16pt;">根据id查询备选方案(熔断)</font></div><div><font style="font-size: 16pt;">    */</font></div><div><font style="font-size: 16pt;">    public Dept hystrixGet(@PathVariable(&quot;id&quot;) Long id){</font></div><div><font style="font-size: 16pt;">        return new Dept().setDeptno(id)</font></div><div><font style="font-size: 16pt;">                .setDname(&quot;id==&gt;&quot;+id+&quot;不存在该用户，或者信息无法找到~ Null-@HyStrix&quot;)</font></div><div><font style="font-size: 16pt;">                .setDb_source(&quot;no this database in MySQL!&quot;);</font></div><div><font style="font-size: 16pt;">    }</font></div><div><font style="font-size: 16pt;">}</font></div><div><br/></div></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br/></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt;">3.主启动类</span></div><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><font style="font-size: 16pt;">package cn.edu.zzu;</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;</font></div><div><font style="font-size: 16pt;">import org.springframework.boot.SpringApplication;</font></div><div><font style="font-size: 16pt;">import org.springframework.boot.autoconfigure.SpringBootApplication;</font></div><div><font style="font-size: 16pt;">import org.springframework.boot.web.servlet.ServletRegistrationBean;</font></div><div><font style="font-size: 16pt;">import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;</font></div><div><font style="font-size: 16pt;">import org.springframework.cloud.client.discovery.EnableDiscoveryClient;</font></div><div><font style="font-size: 16pt;">import org.springframework.cloud.netflix.eureka.EnableEurekaClient;</font></div><div><font style="font-size: 16pt;">import org.springframework.context.annotation.Bean;</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">@SpringBootApplication</font></div><div><font style="font-size: 16pt;">@EnableEurekaClient</font></div><div><font style="font-size: 16pt;">@EnableDiscoveryClient//默认服务发现开启，不需要手动开启</font></div><div><font style="font-size: 16pt;">@EnableCircuitBreaker //Hystrix 添加对熔断的支持</font></div><div><font style="font-size: 16pt;">public class DeptProviderHystrix_8001{</font></div><div><font style="font-size: 16pt;">    public static void main(String[] args) {</font></div><div><font style="font-size: 16pt;">        SpringApplication.run(DeptProviderHystrix_8001.class ,args);</font></div><div><font style="font-size: 16pt;">    }</font></div><div><font style="font-size: 16pt;">}</font></div></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br/></div><div style="text-align: center; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt;"><img src="./index/Image [28].png" type="image/png" data-filename="Image.png"/></span><span style="font-size: 16pt;"><img src="./index/Image [29].png" type="image/png" data-filename="Image.png" width="464"/></span></div></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">而不适用熔断的springcloud-provider-dept–8001模块访问相同地址会出现下面状况:</span></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;; font-variant-caps: normal; font-variant-ligatures: normal;"><img src="./index/Image [30].png" type="image/png" data-filename="Image.png"/></span></font></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">因此，</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">为了避免因某个微服务后台出现异常或错误而导致整个应用或网页报错，使用熔断是必要的</span></font></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt;"><br/></span></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt;"><span style="font-size: 16pt; color: rgb(255, 0, 0); font-weight: bold;">三、服务降级</span></span></div><h5 style="box-sizing: border-box; padding: 0px; margin: 1em 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.4;">1.什么是服务降级?</span></span></h5><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">服务降级是指当服务器压力剧增的情况下，根据实际业务情况及流量，对一些服务和页面有策略的不处理，或换种简单的方式处理，从而释放服务器资源以保证核心业务正常运作或高效运作。说白了，</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">就是尽可能的把系统资源让给优先级高的服务</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">。</span></font></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">资源有限，而请求是无限的。如果在并发高峰期，不做服务降级处理，一方面肯定会影响整体服务的性能，严重的话可能会导致宕机某些重要的服务不可用。所以，一般在高峰期，为了保证核心功能服务的可用性，都要对某些服务降级处理。比如当双11活动时，把交易无关的服务统统降级，如查看蚂蚁深林，查看历史订单等等。</span></span></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">服务降级主要用于什么场景呢？当整个微服务架构整体的负载超出了预设的上限阈值或即将到来的流量预计将会超过预设的阈值时，为了保证重要或基本的服务能正常运行，可以将一些 不重要 或 不紧急 的服务或任务进行服务的 延迟使用 或 暂停使用。</span></span></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">降级的方式可以根据业务来，可以延迟服务，比如延迟给用户增加积分，只是放到一个缓存中，等服务平稳之后再执行 ；或者在粒度范围内关闭服务，比如关闭相关文章的推荐。</span></span></div></li></ul><div style="text-align: center; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;; font-variant-caps: normal; font-variant-ligatures: normal;"><img src="./index/Image [31].png" type="image/png" data-filename="Image.png" width="763"/></span></font></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">由上图可得，</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">当某一时间内服务A的访问量暴增，而B和C的访问量较少，为了缓解A服务的压力，这时候需要B和C暂时关闭一些服务功能，去承担A的部分服务，从而为A分担压力，叫做服务降级</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">。</span></font></div><h5 style="box-sizing: border-box; padding: 0px; margin: 1em 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.4;">服务降级需要考虑的问题</span></span></h5><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important; text-align: left;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">1）那些服务是核心服务，哪些服务是非核心服务</span></span></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important; text-align: left;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">2）那些服务可以支持降级，那些服务不能支持降级，降级策略是什么</span></span></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important; text-align: left;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">3）除服务降级之外是否存在更复杂的业务放通场景，策略是什么？</span></span></div></li></ul><h5 style="box-sizing: border-box; padding: 0px; margin: 1em 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.4;">自动降级分类</span></span></h5><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">1）超时降级：主要配置好超时时间和超时重试次数和机制，并使用异步机制探测回复情况</span></span></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">2）失败次数降级：主要是一些不稳定的api，当失败调用次数达到一定阀值自动降级，同样要使用异步机制探测回复情况</span></span></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">3）故障降级：比如要调用的远程服务挂掉了（网络故障、DNS故障、http服务返回错误的状态码、rpc服务抛出异常），则可以直接降级。降级后的处理方案有：默认值（比如库存服务挂了，返回默认现货）、兜底数据（比如广告挂了，返回提前准备好的一些静态页面）、缓存（之前暂存的一些缓存数据）</span></span></div></li><li><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">4）限流降级：秒杀或者抢购一些限购商品时，此时可能会因为访问量太大而导致系统崩溃，此时会使用限流来进行限制访问量，当达到限流阀值，后续请求会被降级；降级后的处理方案可以是：排队页面（将用户导流到排队页面等一会重试）、无货（直接告知用户没货了）、错误页（如活动太火爆了，稍后重试）。</span></font></div></li></ul><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;; font-weight: bold;">2.</span> <span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">在springcloud-api模块下的service包中新建降级配置类DeptClientServiceFallBackFactory.java</span></div><ul><li><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">基于feign实现服务降级</span></font></div></li></ul><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt;">DeptClientServiceFallbackFactory.java</span></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><font style="font-size: 16pt;">package cn.edu.zzu.service;</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">import cn.edu.zzu.domain.Dept;</font></div><div><font style="font-size: 16pt;">import feign.hystrix.FallbackFactory;</font></div><div><font style="font-size: 16pt;">import org.springframework.stereotype.Component;</font></div><div><font style="font-size: 16pt;">import org.springframework.web.bind.annotation.GetMapping;</font></div><div><font style="font-size: 16pt;">import org.springframework.web.bind.annotation.PathVariable;</font></div><div><font style="font-size: 16pt;">import org.springframework.web.bind.annotation.PostMapping;</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">import java.util.List;</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">/**</font></div><div><font style="font-size: 16pt;">* 服务降级</font></div><div><font style="font-size: 16pt;">*/</font></div><div><font style="font-size: 16pt;">@Component</font></div><div><font style="font-size: 16pt;">public class DeptClientServiceFallbackFactory implements FallbackFactory {</font></div><div><font style="font-size: 16pt;">    @Override</font></div><div><font style="font-size: 16pt;">    public IDeptClientService create(Throwable throwable) {</font></div><div><font style="font-size: 16pt;">        return new IDeptClientService() {</font></div><div><font style="font-size: 16pt;">            @Override</font></div><div><font style="font-size: 16pt;">            @PostMapping(&quot;/dept/addDept&quot;)</font></div><div><font style="font-size: 16pt;">            public boolean addDept(Dept dept) {</font></div><div><font style="font-size: 16pt;">                return false;</font></div><div><font style="font-size: 16pt;">            }</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">            @Override</font></div><div><font style="font-size: 16pt;">            @GetMapping(&quot;/dept/get/{id}&quot;)</font></div><div><font style="font-size: 16pt;">            public Dept findDeptById(@PathVariable(&quot;id&quot;) Long id) {</font></div><div><font style="font-size: 16pt;">                return new Dept().setDeptno(id)</font></div><div><font style="font-size: 16pt;">                        .setDname(&quot;id==&gt;&quot;+id+&quot;没有对应信息，客户端提供了降级信息，这个服务现在已经被关闭了，~ Null-@HyStrix&quot;)</font></div><div><font style="font-size: 16pt;">                        .setDb_source(&quot;没有数据~!&quot;);</font></div><div><font style="font-size: 16pt;">            }</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">            @Override</font></div><div><font style="font-size: 16pt;">            @GetMapping(&quot;/dept/findAll&quot;)</font></div><div><font style="font-size: 16pt;">            public List&lt;Dept&gt; findAll() {</font></div><div><font style="font-size: 16pt;">                return null;</font></div><div><font style="font-size: 16pt;">            }</font></div><div><font style="font-size: 16pt;">        };</font></div><div><font style="font-size: 16pt;">    }</font></div><div><font style="font-size: 16pt;">}</font></div></div><div><br/></div></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">在DeptClientService中指定降级配置类DeptClientServiceFallBackFactory</span></span></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br/></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><font style="font-size: 16pt;"><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">package cn.edu.zzu.service;</span></font></div><div><br/></div><div><br/></div><div><font style="font-size: 16pt;"><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">import cn.edu.zzu.domain.Dept;</span></font></div><div><font style="font-size: 16pt;"><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">import org.springframework.cloud.openfeign.FeignClient;</span></font></div><div><font style="font-size: 16pt;"><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">import org.springframework.stereotype.Component;</span></font></div><div><font style="font-size: 16pt;"><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">import org.springframework.web.bind.annotation.GetMapping;</span></font></div><div><font style="font-size: 16pt;"><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">import org.springframework.web.bind.annotation.PathVariable;</span></font></div><div><font style="font-size: 16pt;"><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">import org.springframework.web.bind.annotation.PostMapping;</span></font></div><div><font style="font-size: 16pt;"><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">import org.springframework.web.bind.annotation.RequestMapping;</span></font></div><div><br/></div><div><br/></div><div><font style="font-size: 16pt;"><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">import java.util.List;</span></font></div><div><br/></div><div><br/></div><div><font style="font-size: 16pt;"><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">/**</span></font></div><div><font style="font-size: 16pt;"><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">* 负载均衡 feign</span></font></div><div><font style="font-size: 16pt;"><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">* 请求访问服务提供者的接口信息,请求路径要保持和provider的controller中的path一致才可以</span></font></div><div><font style="font-size: 16pt;"><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">*/</span></font></div><div><font style="font-size: 16pt;"><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">@Component</span></font></div><div><font style="font-size: 16pt;">//@FeignClient:微服务客户端注解,value:指定微服务的名字,这样就可以使Feign客户端直接找到对应的微服务</font></div><div><font style="font-size: 16pt;"><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">@FeignClient(value = &quot;SPRINGCLOUD-PROVIDER-DEPT&quot;,fallbackFactory = DeptClientServiceFallbackFactory.class)</span></font></div><div><font style="font-size: 16pt;">//fallbackFactory指定降级配置类</font></div><div><font style="font-size: 16pt;"><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">@RequestMapping(&quot;/dept&quot;)</span></font></div><div><font style="font-size: 16pt;"><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">public interface IDeptClientService {</span></font></div><div><font style="font-size: 16pt;"><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">    /**</span></font></div><div><font style="font-size: 16pt;"><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">     * 添加部门</span></font></div><div><font style="font-size: 16pt;"><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">     * @param dept</span></font></div><div><font style="font-size: 16pt;"><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">     * @return</span></font></div><div><font style="font-size: 16pt;"><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">     */</span></font></div><div><br/></div><div><br/></div><div><font style="font-size: 16pt;"><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">    @PostMapping(&quot;/addDept&quot;)</span></font></div><div><font style="font-size: 16pt;"><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">    boolean addDept(Dept dept);</span></font></div><div><br/></div><div><br/></div><div><font style="font-size: 16pt;"><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">    /**</span></font></div><div><font style="font-size: 16pt;"><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">     * 根据id查询</span></font></div><div><font style="font-size: 16pt;"><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">     * @param id</span></font></div><div><font style="font-size: 16pt;"><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">     * @return</span></font></div><div><font style="font-size: 16pt;"><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">     */</span></font></div><div><font style="font-size: 16pt;"><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">    @GetMapping(&quot;/get/{id}&quot;)</span></font></div><div><font style="font-size: 16pt;"><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">    Dept findDeptById(@PathVariable(&quot;id&quot;) Long id);</span></font></div><div><br/></div><div><br/></div><div><font style="font-size: 16pt;"><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">    /**</span></font></div><div><font style="font-size: 16pt;"><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">     * 查询所有</span></font></div><div><font style="font-size: 16pt;"><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">     * @return</span></font></div><div><font style="font-size: 16pt;"><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">     */</span></font></div><div><font style="font-size: 16pt;"><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">    @GetMapping(&quot;/getAll&quot;)</span></font></div><div><font style="font-size: 16pt;"><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">    List&lt;Dept&gt; findAll();</span></font></div><div><font style="font-size: 16pt;"><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">}</span></font></div></div></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">在</span><span style="box-sizing: border-box; border-radius: 20px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">springcloud-consumer-dept-feign</span><span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">模块中开启降级：</span></font></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;">server:</font></span></div><div><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;">  port: 80</font></span></div><div><br/></div><div><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;">eureka:</font></span></div><div><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;">  client:</font></span></div><div><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;">    register-with-eureka: false #不向eureka注册自己</font></span></div><div><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;">    service-url:</font></span></div><div><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;">     defaultZone: http://eureka7001.com:7001/eureka/,http://eureka7002.com:7002/eureka/,http://eureka7003.com:7003/eureka/</font></span></div><div><br/></div><div><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;">#feign 熔断降级</font></span></div><div><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;">feign:</font></span></div><div><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;">  hystrix:</font></span></div><div><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;">    enabled: true</font></span></div></div><div><br/></div></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"></div><h4 style="box-sizing: border-box; padding: 0px; margin: 1em 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Microsoft Yahei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.4;">3. 服务熔断和降级的区别</span></span></h4><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important; text-align: left;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-weight: bold;">服务熔断—&gt;服务端</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;">：某个服务超时或异常，引起熔断~，类似于保险丝(自我熔断)</span></font></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important; text-align: left;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-weight: bold;">服务降级—&gt;客户端</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;">：从整体网站请求负载考虑，当某个服务熔断或者关闭之后，服务将不再被调用，此时在客户端，我们可以准备一个 FallBackFactory ，返回一个默认的值(缺省值)。会导致整体的服务下降，但是好歹能用，比直接挂掉强。</span></font></div></li><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important; text-align: left;"><span style="font-size: 16pt; color: unset; font-family: unset;">触发原因不太一样，服务熔断一般是某个服务（下游服务）故障引起，而服务降级一般是从整体负荷考虑；管理目标的层次不太一样，熔断其实是一个框架级的处理，每个微服务都需要（无层级之分），而降级一般需要对业务有层级之分（比如降级一般是从最外围服务开始）</span></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important; text-align: left;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;">实现方式不太一样，服务降级具有代码侵入性(由控制器完成/或自动降级)，熔断一般称为</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-weight: bold;">自我熔断</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); font-size: 16pt;">。</span></font></div></li></ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">熔断，降级，限流</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">：</span></font></div></li><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">限流：限制并发的请求访问量，超过阈值则拒绝；</span></span></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">降级：服务分优先级，牺牲非核心服务（不可用），保证核心服务稳定；从整体负荷考虑；</span></span></div></li><li><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">熔断：依赖的下游服务故障触发熔断，避免引发本系统崩溃；系统自动执行和恢复</span></font></div></li></ul></ul><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="font-size: 16pt; color: rgb(255, 0, 0); font-weight: bold;">四、监控面板</span></font></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"></div><h4 style="box-sizing: border-box; padding: 0px; margin: 1em 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); position: relative; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Microsoft Yahei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.4;">Dashboard 流监控、</span><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;WenQuanYi Micro Hei&quot;, &quot;Microsoft Yahei&quot;, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold; line-height: 1.4;">新建springcloud-consumer-hystrix-dashboard-9001模块</span></h4><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt;">1.Pom.xml添加依赖</span></div><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><font style="font-size: 16pt;">&lt;dependencies&gt;</font></div><div><font style="font-size: 16pt;">    &lt;!--Hystrix依赖--&gt;</font></div><div><font style="font-size: 16pt;">    &lt;dependency&gt;</font></div><div><font style="font-size: 16pt;">        &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;</font></div><div><font style="font-size: 16pt;">        &lt;artifactId&gt;spring-cloud-starter-hystrix&lt;/artifactId&gt;</font></div><div><font style="font-size: 16pt;">        &lt;version&gt;1.4.7.RELEASE&lt;/version&gt;</font></div><div><font style="font-size: 16pt;">    &lt;/dependency&gt;</font></div><div><font style="font-size: 16pt;">    &lt;!--dashboard依赖--&gt;</font></div><div><font style="font-size: 16pt;">    &lt;dependency&gt;</font></div><div><font style="font-size: 16pt;">        &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;</font></div><div><font style="font-size: 16pt;">        &lt;artifactId&gt;spring-cloud-starter-hystrix-dashboard&lt;/artifactId&gt;</font></div><div><font style="font-size: 16pt;">        &lt;version&gt;1.4.7.RELEASE&lt;/version&gt;</font></div><div><font style="font-size: 16pt;">    &lt;/dependency&gt;</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">    &lt;!--ribbon负载均衡  轮询默认--&gt;</font></div><div><font style="font-size: 16pt;">    &lt;dependency&gt;</font></div><div><font style="font-size: 16pt;">        &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;</font></div><div><font style="font-size: 16pt;">        &lt;artifactId&gt;spring-cloud-starter-ribbon&lt;/artifactId&gt;</font></div><div><font style="font-size: 16pt;">        &lt;version&gt;1.4.7.RELEASE&lt;/version&gt;</font></div><div><font style="font-size: 16pt;">    &lt;/dependency&gt;</font></div><div><font style="font-size: 16pt;">    &lt;!--eureka 客户端--&gt;</font></div><div><font style="font-size: 16pt;">    &lt;dependency&gt;</font></div><div><font style="font-size: 16pt;">        &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;</font></div><div><font style="font-size: 16pt;">        &lt;artifactId&gt;spring-cloud-starter-eureka&lt;/artifactId&gt;</font></div><div><font style="font-size: 16pt;">        &lt;version&gt;1.4.7.RELEASE&lt;/version&gt;</font></div><div><font style="font-size: 16pt;">    &lt;/dependency&gt;</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">    &lt;dependency&gt;</font></div><div><font style="font-size: 16pt;">        &lt;groupId&gt;cn.edu.zzu&lt;/groupId&gt;</font></div><div><font style="font-size: 16pt;">        &lt;artifactId&gt;Springcloud-api&lt;/artifactId&gt;</font></div><div><font style="font-size: 16pt;">        &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;</font></div><div><font style="font-size: 16pt;">    &lt;/dependency&gt;</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">    &lt;dependency&gt;</font></div><div><font style="font-size: 16pt;">        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;</font></div><div><font style="font-size: 16pt;">        &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;</font></div><div><font style="font-size: 16pt;">    &lt;/dependency&gt;</font></div><div><font style="font-size: 16pt;">&lt;/dependencies&gt;</font></div></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt;">2.</span> <span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">给springcloud-provider-dept-hystrix-8001模块下的主启动类添加如下代码,添加监控</span></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><font style="font-size: 16pt;">package cn.edu.zzu;</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;</font></div><div><font style="font-size: 16pt;">import org.springframework.boot.SpringApplication;</font></div><div><font style="font-size: 16pt;">import org.springframework.boot.autoconfigure.SpringBootApplication;</font></div><div><font style="font-size: 16pt;">import org.springframework.boot.web.servlet.ServletRegistrationBean;</font></div><div><font style="font-size: 16pt;">import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;</font></div><div><font style="font-size: 16pt;">import org.springframework.cloud.client.discovery.EnableDiscoveryClient;</font></div><div><font style="font-size: 16pt;">import org.springframework.cloud.netflix.eureka.EnableEurekaClient;</font></div><div><font style="font-size: 16pt;">import org.springframework.context.annotation.Bean;</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">@SpringBootApplication</font></div><div><font style="font-size: 16pt;">@EnableEurekaClient</font></div><div><font style="font-size: 16pt;">@EnableDiscoveryClient//默认服务发现开启，不需要手动开启</font></div><div><font style="font-size: 16pt;">@EnableCircuitBreaker //Hystrix 添加对熔断的支持</font></div><div><font style="font-size: 16pt;">public class DeptProviderHystrix_8001{</font></div><div><font style="font-size: 16pt;">    public static void main(String[] args) {</font></div><div><font style="font-size: 16pt;">        SpringApplication.run(DeptProviderHystrix_8001.class ,args);</font></div><div><font style="font-size: 16pt;">    }</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">    //增加一个 Servlet，添加监控流、依赖要有</font><font style="font-size: 16pt;">actuator、hystrix</font></div><div><font style="font-size: 16pt;">    @Bean</font></div><div><font style="font-size: 16pt;">    public ServletRegistrationBean hystrixMetricsStreamServlet(){</font></div><div><font style="font-size: 16pt;">        ServletRegistrationBean registrationBean = new ServletRegistrationBean(new HystrixMetricsStreamServlet());</font></div><div><font style="font-size: 16pt;">        //访问该页面就是监控页面</font></div><div><font style="font-size: 16pt;">        registrationBean.addUrlMappings(&quot;/actuator/hystrix.stream&quot;);</font></div><div><font style="font-size: 16pt;">        return registrationBean;</font></div><div><font style="font-size: 16pt;">    }</font></div><div><font style="font-size: 16pt;">}</font></div></div><div><br/></div></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt;">3.</span><span style="font-size: 16pt;">springcloud-consumer-hystrix-dashboard-9001 主启动类</span></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><font style="font-size: 16pt;">package cn.edu.zzu;</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">import org.springframework.boot.SpringApplication;</font></div><div><font style="font-size: 16pt;">import org.springframework.boot.autoconfigure.SpringBootApplication;</font></div><div><font style="font-size: 16pt;">import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">@SpringBootApplication</font></div><div><font style="font-size: 16pt;">// 开启Dashboard</font></div><div><font style="font-size: 16pt;">@EnableHystrixDashboard</font></div><div><font style="font-size: 16pt;">public class DeptConsumerDashboard_9001 {</font></div><div><font style="font-size: 16pt;">    public static void main(String[] args) {</font></div><div><font style="font-size: 16pt;">        SpringApplication.run(DeptConsumerDashboard_9001.class , args);</font></div><div><font style="font-size: 16pt;">    }</font></div><div><font style="font-size: 16pt;">}</font></div></div><div><br/></div></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt;">4.访问</span><span style="font-size: 16pt;"><a href="http://127.0.0.1:9001/hystrix" style="font-size: 16pt;">http://127.0.0.1:9001/hystrix</a> 流的链接为springcloud-dept-provider-hystrix的主启动类中配置的servlet的地址</span></div><div style="text-align: center; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt;"><img src="./index/Image [32].png" type="image/png" data-filename="Image.png" width="944"/></span></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt;">进入后能够显示每个服务的健康状况：</span></div><div style="text-align: center; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt;"><img src="./index/Image [33].png" type="image/png" data-filename="Image.png" width="1235"/></span></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt;"><br/></span></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt;"><br/></span></div><div style="text-align: center; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt;"><img src="./index/Image [34].png" type="image/png" data-filename="Image.png" width="637"/></span></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt;"><br/></span></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt;"><br/></span></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt;"><br/></span></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt;"><br/></span></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt;"><br/></span></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt;"><br/></span></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt;"><br/></span></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt;"><br/></span></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt;"><br/></span></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt;"><br/></span></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt;"><br/></span></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt;"><br/></span></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt;"><br/></span></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt;"><br/></span></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt;"><br/></span></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt;"><br/></span></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt;"><br/></span></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt;"><br/></span></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt;"><br/></span></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt;"><br/></span></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt;"><br/></span></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt;"><br/></span></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt;"><br/></span></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt;"><br/></span></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt;"><br/></span></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt;"><br/></span></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt;"><br/></span></div><div><br/></div></div><div><br/></div><div><br/></div><div><div><br/></div><table bgcolor="#D4DDE5" border="0" width="100%"><colgroup><col></col></colgroup><tbody><tr><td><h1>07 - SpringCloud Zuul 学习环境搭建 ：路由网关</h1><div><span style="font-weight: bold;">来源网址：</span> <a href="https://www.kuangstudy.com/bbs/1374942542566551554">https://www.kuangstudy.com/bbs/1374942542566551554</a></div><div><span style="font-weight: bold;">作者：</span> syra-</div></td></tr></tbody></table><div><br/></div></div><div><div><span style="font-size: 16pt;">07 - SpringCloud Zuul 学习环境搭建 ：路由网关 </span></div><div><span style="font-size: 16pt;"><br/></span></div><div><span style="font-size: 16pt;">springcloud-zuul-9527</span></div><div><span style="font-size: 16pt;"><br/></span></div><div><span style="font-size: 16pt;"><span style="font-size: 16pt; color: rgb(255, 0, 0); font-weight: bold;">一、理论知识</span></span></div><div><font style="font-size: 16pt;"><br/></font></div><blockquote style="box-sizing: border-box; padding: 10px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); border-left: 4px solid rgb(139, 195, 74); background: rgb(248, 248, 248); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div style="box-sizing: border-box; padding: 0px; margin: 0px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt; color: rgb(102, 102, 102); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">什么是zuul?</span></span></div></blockquote><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">Zull包含了对请求的</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">路由</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">(用来跳转的)和</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">过滤</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">两个最主要功能：</span></font></div></li><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">其中</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">路由功能负责将外部请求转发到具体的微服务实例上，是实现外部访问统一入口的基础</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">，而过</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">滤器功能则负责对请求的处理过程进行干预，是实现请求校验，服务聚合等功能的基础</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">。Zuul和Eureka进行整合，将Zuul自身注册为Eureka服务治理下的应用，同时从Eureka中获得其他服务的消息，也即以后的访问微服务都是通过Zuul跳转后获得。</span></font></div></li></ul></ul><div style="text-align: center; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;; font-variant-caps: normal; font-variant-ligatures: normal;"><img src="./index/Image [35].png" type="image/png" data-filename="Image.png"/></span></font></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">注意</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">：Zuul 服务最终还是会注册进 Eureka</span></font></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">提供</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">：代理 + 路由 + 过滤 三大功能！</span></font></div><blockquote style="box-sizing: border-box; padding: 10px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); border-left: 4px solid rgb(139, 195, 74); background: rgb(248, 248, 248); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div style="box-sizing: border-box; padding: 0px; margin: 0px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt; color: rgb(102, 102, 102); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">Zuul 能干嘛？</span></span></div></blockquote><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">路由</span></span></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">过滤</span></span></div></li><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">官方文档：</span><a href="https://github.com/Netflix/zuul/" style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background: transparent; font-size: 16pt; color: rgb(255, 0, 0); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">https://github.com/Netflix/zuul/</a></font></div></li></ul></ul><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="font-size: 16pt; color: rgb(255, 0, 0); font-weight: bold;">二、 入门案例</span></font></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; border-radius: 20px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">1.新建springcloud-zuul模块，并导入依赖</span></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br/></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><span style="color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;;"><font style="font-size: 16pt;">&lt;dependencies&gt;</font></span></div><div><span style="color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;;"><font style="font-size: 16pt;">    &lt;!--zuul--&gt;</font></span></div><div><span style="color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;;"><font style="font-size: 16pt;">    &lt;dependency&gt;</font></span></div><div><span style="color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;;"><font style="font-size: 16pt;">        &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;</font></span></div><div><span style="color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;;"><font style="font-size: 16pt;">        &lt;artifactId&gt;spring-cloud-starter-zuul&lt;/artifactId&gt;</font></span></div><div><span style="color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;;"><font style="font-size: 16pt;">        &lt;version&gt;1.4.7.RELEASE&lt;/version&gt;</font></span></div><div><span style="color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;;"><font style="font-size: 16pt;">    &lt;/dependency&gt;</font></span></div><div><span style="color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;;"><font style="font-size: 16pt;">    &lt;!--Hystrix依赖--&gt;</font></span></div><div><span style="color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;;"><font style="font-size: 16pt;">    &lt;dependency&gt;</font></span></div><div><span style="color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;;"><font style="font-size: 16pt;">        &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;</font></span></div><div><span style="color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;;"><font style="font-size: 16pt;">        &lt;artifactId&gt;spring-cloud-starter-hystrix&lt;/artifactId&gt;</font></span></div><div><span style="color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;;"><font style="font-size: 16pt;">        &lt;version&gt;1.4.7.RELEASE&lt;/version&gt;</font></span></div><div><span style="color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;;"><font style="font-size: 16pt;">    &lt;/dependency&gt;</font></span></div><div><span style="color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;;"><font style="font-size: 16pt;">    &lt;!--dashboard依赖--&gt;</font></span></div><div><span style="color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;;"><font style="font-size: 16pt;">    &lt;dependency&gt;</font></span></div><div><span style="color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;;"><font style="font-size: 16pt;">        &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;</font></span></div><div><span style="color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;;"><font style="font-size: 16pt;">        &lt;artifactId&gt;spring-cloud-starter-hystrix-dashboard&lt;/artifactId&gt;</font></span></div><div><span style="color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;;"><font style="font-size: 16pt;">        &lt;version&gt;1.4.7.RELEASE&lt;/version&gt;</font></span></div><div><span style="color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;;"><font style="font-size: 16pt;">    &lt;/dependency&gt;</font></span></div><div><br/></div><div><span style="color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;;"><font style="font-size: 16pt;">    &lt;!--ribbon负载均衡  轮询默认--&gt;</font></span></div><div><span style="color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;;"><font style="font-size: 16pt;">    &lt;dependency&gt;</font></span></div><div><span style="color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;;"><font style="font-size: 16pt;">        &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;</font></span></div><div><span style="color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;;"><font style="font-size: 16pt;">        &lt;artifactId&gt;spring-cloud-starter-ribbon&lt;/artifactId&gt;</font></span></div><div><span style="color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;;"><font style="font-size: 16pt;">        &lt;version&gt;1.4.7.RELEASE&lt;/version&gt;</font></span></div><div><span style="color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;;"><font style="font-size: 16pt;">    &lt;/dependency&gt;</font></span></div><div><span style="color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;;"><font style="font-size: 16pt;">    &lt;!--eureka 客户端--&gt;</font></span></div><div><span style="color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;;"><font style="font-size: 16pt;">    &lt;dependency&gt;</font></span></div><div><span style="color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;;"><font style="font-size: 16pt;">        &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;</font></span></div><div><span style="color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;;"><font style="font-size: 16pt;">        &lt;artifactId&gt;spring-cloud-starter-eureka&lt;/artifactId&gt;</font></span></div><div><span style="color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;;"><font style="font-size: 16pt;">        &lt;version&gt;1.4.7.RELEASE&lt;/version&gt;</font></span></div><div><span style="color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;;"><font style="font-size: 16pt;">    &lt;/dependency&gt;</font></span></div><div><br/></div><div><span style="color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;;"><font style="font-size: 16pt;">    &lt;dependency&gt;</font></span></div><div><span style="color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;;"><font style="font-size: 16pt;">        &lt;groupId&gt;cn.edu.zzu&lt;/groupId&gt;</font></span></div><div><span style="color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;;"><font style="font-size: 16pt;">        &lt;artifactId&gt;Springcloud-api&lt;/artifactId&gt;</font></span></div><div><span style="color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;;"><font style="font-size: 16pt;">        &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;</font></span></div><div><span style="color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;;"><font style="font-size: 16pt;">    &lt;/dependency&gt;</font></span></div><div><br/></div><div><span style="color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;;"><font style="font-size: 16pt;">    &lt;dependency&gt;</font></span></div><div><span style="color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;;"><font style="font-size: 16pt;">        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;</font></span></div><div><span style="color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;;"><font style="font-size: 16pt;">        &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;</font></span></div><div><span style="color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;;"><font style="font-size: 16pt;">    &lt;/dependency&gt;</font></span></div><div><span style="color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;;"><font style="font-size: 16pt;">&lt;/dependencies&gt;</font></span></div></div><div><br/></div></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;; font-weight: bold;">2.application.yml</span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><font style="font-size: 16pt;">server:</font></div><div><font style="font-size: 16pt;">  port: 9527</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">spring:</font></div><div><font style="font-size: 16pt;">  application:</font></div><div><font style="font-size: 16pt;">    name: springcloud-zuul</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">#eureka</font></div><div><font style="font-size: 16pt;">eureka:</font></div><div><font style="font-size: 16pt;">  client:</font></div><div><font style="font-size: 16pt;">    service-url:</font></div><div><font style="font-size: 16pt;">      defaultZone: http://eureka7001.com:7001/eureka/,http://eureka7002.com:7002/eureka/,http://eureka7003.com:7003/eureka/</font></div><div><font style="font-size: 16pt;">  instance:</font></div><div><font style="font-size: 16pt;">    instance-id: springcloud-provider-zuul-9527 #修改eureka的默认配置信息</font></div><div><font style="font-size: 16pt;">    prefer-ip-address: true</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">info:</font></div><div><font style="font-size: 16pt;">  app.name: test.zuul</font></div><div><font style="font-size: 16pt;">  company.name: zuul.com</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">zuul: #http://localhost:9527/springcloud-provider-dept/dept/get/1</font></div><div><font style="font-size: 16pt;">  routes:</font></div><div><font style="font-size: 16pt;">    #服务请求路径别名  http://localhost:9527/mydept/dept/get/1</font></div><div><font style="font-size: 16pt;">    mydept.serviceId: springcloud-provider-dept</font></div><div><font style="font-size: 16pt;">    mydept.path: /mydept/**</font></div><div><font style="font-size: 16pt;">  ignored-services: springcloud-provider-dept # 不能在使用该名称进行服务访问  “*” 隐藏全部</font></div><div><font style="font-size: 16pt;">  prefix: /zzu #公共访问前缀</font></div><div><font style="font-size: 16pt;">  #http://localhost:9527/zzu/mydept/dept/get/1</font></div></div></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; border-radius: 20px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt;">3.主启动类</span></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><span style="box-sizing: border-box; border-radius: 20px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;">package cn.edu.zzu;</font></span></div><div><br/></div><div><span style="box-sizing: border-box; border-radius: 20px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;">import org.springframework.boot.SpringApplication;</font></span></div><div><span style="box-sizing: border-box; border-radius: 20px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;">import org.springframework.boot.autoconfigure.SpringBootApplication;</font></span></div><div><span style="box-sizing: border-box; border-radius: 20px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;">import org.springframework.cloud.netflix.zuul.EnableZuulProxy;</font></span></div><div><br/></div><div><span style="box-sizing: border-box; border-radius: 20px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;">@SpringBootApplication</font></span></div><div><span style="box-sizing: border-box; border-radius: 20px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;">@EnableZuulProxy //启动zuul网关</font></span></div><div><span style="box-sizing: border-box; border-radius: 20px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;">public class ZuulApplication {</font></span></div><div><span style="box-sizing: border-box; border-radius: 20px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;">    public static void main(String[] args) {</font></span></div><div><span style="box-sizing: border-box; border-radius: 20px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;">        SpringApplication.run(ZuulApplication.class ,args);</font></span></div><div><span style="box-sizing: border-box; border-radius: 20px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;">    }</font></span></div><div><span style="box-sizing: border-box; border-radius: 20px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;">}</font></span></div></div><div><br/></div></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt;">4.zuul服务依托eureka，注册后访问zuul服务即可代理访问到provider</span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt;"><img src="./index/Image [36].png" type="image/png" data-filename="Image.png"/></span></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt;"><br/></span></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt;">5.请求路径的配置</span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">可以看出Zull路由网关被注册到Eureka注册中心中了！</span></span></div><div style="text-align: center; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;; font-variant-caps: normal; font-variant-ligatures: normal;"><img src="./index/Image [37].png" type="image/png" data-filename="Image.png"/></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">上图是没有经过Zull路由网关配置时，服务接口访问的路由，可以看出直接用微服务(服务提供方)名称去访问，这样不安全，不能将微服务名称暴露！</span></span></div><div style="text-align: left; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">所以经过Zull路由网关配置后，访问的路由为：</span></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div><span style="box-sizing: border-box; border-radius: 20px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt;">访问路由网关代理后的请求   </span><a href="http://localhost:9527/zzu/mydept/dept/get/1" style="box-sizing: border-box; border-radius: 20px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; font-family: &quot;JetBrains Mono&quot;, monospace; font-style: italic;">http://localhost:9527/zzu/mydept/dept/get/1</a></div></div><div style="text-align: center; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><img src="./index/Image [38].png" type="image/png" data-filename="Image.png"/></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><font style="font-size: 16pt;">zuul: #http://localhost:9527/springcloud-provider-dept/dept/get/1</font></div><div><font style="font-size: 16pt;">  routes:</font></div><div><font style="font-size: 16pt;">    #服务请求路径别名  http://localhost:9527/mydept/dept/get/1</font></div><div><font style="font-size: 16pt;">    mydept.serviceId: springcloud-provider-dept</font></div><div><font style="font-size: 16pt;">    mydept.path: /mydept/**</font></div><div><font style="font-size: 16pt;">  ignored-services: springcloud-provider-dept # 不能在使用该名称进行服务访问  “*” 隐藏全部</font></div><div><font style="font-size: 16pt;">  prefix: /zzu #公共访问前缀</font></div><div><font style="font-size: 16pt;">  #http://localhost:9527/zzu/mydept/dept/get/1</font></div></div></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">我们看到，微服务名称被替换并隐藏，换成了我们自定义的微服务名称mydept，同时加上了前缀haust，这样就做到了对路由fan访问的加密处理！</span></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">详情参考springcloud中文社区zuul组件 :</span><a href="https://www.springcloud.cc/spring-cloud-greenwich.html/#\_router\_and\_filter\_zuul" style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background: transparent; font-size: 16pt; color: rgb(65, 131, 196); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">https://www.springcloud.cc/spring-cloud-greenwich.html\#\_router\_and\_filter\_zuul</a></font></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; border-radius: 20px; font-size: 17px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br/></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; border-radius: 20px; font-size: 17px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br/></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; border-radius: 20px; font-size: 17px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br/></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; border-radius: 20px; font-size: 17px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br/></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; border-radius: 20px; font-size: 17px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br/></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; border-radius: 20px; font-size: 17px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br/></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; border-radius: 20px; font-size: 17px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br/></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; border-radius: 20px; font-size: 17px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br/></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; border-radius: 20px; font-size: 17px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br/></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; border-radius: 20px; font-size: 17px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br/></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; border-radius: 20px; font-size: 17px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br/></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; border-radius: 20px; font-size: 17px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br/></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; border-radius: 20px; font-size: 17px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br/></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; border-radius: 20px; font-size: 17px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br/></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; border-radius: 20px; font-size: 17px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br/></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; border-radius: 20px; font-size: 17px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br/></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; border-radius: 20px; font-size: 17px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br/></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; border-radius: 20px; font-size: 17px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br/></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; border-radius: 20px; font-size: 17px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br/></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; border-radius: 20px; font-size: 17px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br/></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; border-radius: 20px; font-size: 17px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br/></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; border-radius: 20px; font-size: 17px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br/></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; border-radius: 20px; font-size: 17px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br/></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; border-radius: 20px; font-size: 17px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br/></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; border-radius: 20px; font-size: 17px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br/></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; border-radius: 20px; font-size: 17px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br/></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; border-radius: 20px; font-size: 17px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br/></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; border-radius: 20px; font-size: 17px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br/></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; border-radius: 20px; font-size: 17px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br/></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; border-radius: 20px; font-size: 17px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br/></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; border-radius: 20px; font-size: 17px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br/></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; border-radius: 20px; font-size: 17px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br/></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"></div></div><div><br/></div><div><br/></div><div><div><br/></div><table bgcolor="#D4DDE5" border="0" width="100%"><colgroup><col></col></colgroup><tbody><tr><td><h1>08 - SpringCloud Config 学习环境搭建 ：分布式配置</h1><div><span style="font-weight: bold;">来源网址：</span> <a href="https://www.kuangstudy.com/bbs/1374942542566551554">https://www.kuangstudy.com/bbs/1374942542566551554</a></div><div><span style="font-weight: bold;">作者：</span> syra-</div></td></tr></tbody></table><div><br/></div></div><div><div><span style="font-size: 18pt;">08 - SpringCloud Config 学习环境搭建 ：分布式配置 </span></div><div><span style="font-size: 16pt;"><br/></span></div><div><span style="font-size: 16pt;"><br/></span></div><div><span style="font-size: 16pt;"><br/></span></div><div><span style="font-size: 16pt;"><span style="font-size: 16pt; color: rgb(255, 0, 0); font-weight: bold;">一、理论知识</span></span></div><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div><br/></div><div><span style="font-size: 16pt; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); border-radius: 20px; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">Spring Cloud Config为分布式系统中的外部配置提供服务器和客户端支持</span><span style="font-size: 16pt; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">。</span></div></div><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">使用Config Server，您可以在所有环境中管理应用程序的外部属性。</span></font></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">客户端和服务器上的概念映射与Spring</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"> </span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; overflow-wrap: break-word; background: rgb(246, 246, 246); border-radius: 3px; border: 1px solid rgb(238, 238, 238); font-size: 16pt; color: rgb(232, 62, 140); font-family: &quot;YaHei Consolas Hybrid&quot;, Consolas, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Helvetica, monospace, monospace; font-variant-caps: normal; font-variant-ligatures: normal;">Environment</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">和</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; overflow-wrap: break-word; background: rgb(246, 246, 246); border-radius: 3px; border: 1px solid rgb(238, 238, 238); font-size: 16pt; color: rgb(232, 62, 140); font-family: &quot;YaHei Consolas Hybrid&quot;, Consolas, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Helvetica, monospace, monospace; font-variant-caps: normal; font-variant-ligatures: normal;">PropertySource</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">抽象相同，因此它们与Spring应用程序非常契合，但可以与任何以任何语言运行的应用程序一起使用。随着应用程序通过从开发人员到测试和生产的部署流程，您可以管理这些环境之间的配置，并确定应用程序具有迁移时需要运行的一切。服务器存储后端的默认实现使用git，因此它轻松支持标签版本的配置环境，以及可以访问用于管理内容的各种工具。很容易添加替代实现，并使用Spring配置将其插入。</span></font></div></li></ul><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; border-radius: 20px;"><span style="font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">分布式系统面临的–配置文件问题</span></span></div><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">微服务意味着要将单体应用中的业务拆分成一个个子服务，每个服务的粒度相对较小，因此系统中会出现大量的服务，由于每个服务都需要必要的配置信息才能运行，所以一套集中式的，动态的配置管理设施是必不可少的。spring cloud提供了configServer来解决这个问题，我们每一个微服务自己带着一个application.yml，那上百个的配置文件修改起来，令人头疼！</span></span></div></li></ul><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; border-radius: 20px;"><span style="font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">什么是SpringCloud config分布式配置中心？</span></span></div><div style="text-align: center; box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;; font-variant-caps: normal; font-variant-ligatures: normal;"><img src="./index/Image [39].png" type="image/png" data-filename="Image.png"/></span></div><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">spring cloud config 为微服务架构中的微服务提供集中化的外部支持，配置服务器为各个不同微服务应用的所有环节提供了一个</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">中心化的外部配置</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">。</span></font></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">spring cloud config 分为</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">服务端</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">和</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">客户端</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">两部分。</span></font></div></li><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">服务端也称为</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;"> </span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">分布式配置中心</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">，它是一个独立的微服务应用，用来连接配置服务器并为客户端提供获取配置信息，加密，解密信息等访问接口。</span></font></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><font style="font-size: 16pt;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">客户端则是</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; border-radius: 20px; font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">通过指定的配置中心来管理应用资源，以及与业务相关的配置内容，并在启动的时候从配置中心获取和加载配置信息</span><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">。配置服务器默认采用git来存储配置信息，这样就有助于对环境配置进行版本管理。并且可用通过git客户端工具来方便的管理和访问配置内容。</span></font></div></li></ul></ul><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; border-radius: 20px;"><span style="font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">spring cloud config 分布式配置中心能干嘛？</span></span></div><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">集中式管理配置文件</span></span></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">不同环境，不同配置，动态化的配置更新，分环境部署，比如 /dev /test /prod /beta /release</span></span></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">运行期间动态调整配置，不再需要在每个服务部署的机器上编写配置文件，服务会向配置中心统一拉取配置自己的信息</span></span></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">当配置发生变动时，服务不需要重启，即可感知到配置的变化，并应用新的配置</span></span></div></li><li><div style="box-sizing: border-box; padding: 0px; margin: 0px; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); list-style: initial !important;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="font-size: 16pt;">将配置信息以REST接口的形式暴露</span></span></div></li></ul><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; border-radius: 20px;"><span style="font-size: 16pt; color: rgb(24, 24, 24); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">spring cloud config 分布式配置中心与GitHub整合</span></span></div><ul><li><div style="box-sizing: border-box; padding: 0px; margin: 0px 0px 16px; list-style: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">由于spring cloud config 默认使用git来存储配置文件 (也有其他方式，比如自持SVN 和本地文件)，但是最推荐的还是git ，而且使用的是 http / https 访问的形式。</span></span></div></li></ul><div><span style="font-size: 16pt;"><span style="font-size: 16pt; color: rgb(255, 0, 0); font-weight: bold;">二、springcloud-config-server搭建</span></span></div><div><span style="font-size: 16pt;"><br/></span></div><div><span style="font-size: 16pt;">1.pom.xml导入依赖</span></div><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><font style="font-size: 16pt;">&lt;dependencies&gt;</font></div><div><font style="font-size: 16pt;">    &lt;!--springcloud-config--&gt;</font></div><div><font style="font-size: 16pt;">    &lt;dependency&gt;</font></div><div><font style="font-size: 16pt;">        &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;</font></div><div><font style="font-size: 16pt;">        &lt;artifactId&gt;spring-cloud-config-server&lt;/artifactId&gt;</font></div><div><font style="font-size: 16pt;">        &lt;version&gt;2.1.1.RELEASE&lt;/version&gt;</font></div><div><font style="font-size: 16pt;">    &lt;/dependency&gt;</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">    &lt;dependency&gt;</font></div><div><font style="font-size: 16pt;">        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;</font></div><div><font style="font-size: 16pt;">        &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;</font></div><div><font style="font-size: 16pt;">    &lt;/dependency&gt;</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">    &lt;!--actuator--&gt;</font></div><div><font style="font-size: 16pt;">    &lt;dependency&gt;</font></div><div><font style="font-size: 16pt;">        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;</font></div><div><font style="font-size: 16pt;">        &lt;artifactId&gt;spring-boot-starter-actuator&lt;/artifactId&gt;</font></div><div><font style="font-size: 16pt;">    &lt;/dependency&gt;</font></div><div><font style="font-size: 16pt;">&lt;/dependencies&gt;</font></div></div><div><br/></div><div><font style="font-size: 16pt;"><br/></font></div><div><span style="font-size: 16pt;">2.</span> <span style="letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-size: 16pt; color: rgb(51, 51, 51); font-family: &quot;Microsoft YaHei&quot;, Helvetica, &quot;Meiryo UI&quot;, &quot;Malgun Gothic&quot;, &quot;Segoe UI&quot;, &quot;Trebuchet MS&quot;, Monaco, monospace, Tahoma, STXihei, 华文细黑, STHeiti, &quot;Helvetica Neue&quot;, &quot;Droid Sans&quot;, &quot;wenquanyi micro hei&quot;, FreeSans, Arimo, Arial, SimSun, 宋体, Heiti, 黑体, sans-serif; font-variant-caps: normal; font-variant-ligatures: normal;">resource下创建application.yml配置文件，Spring Cloud Config服务器从git存储库（必须提供）为远程客户端提供配置：</span></div><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><font style="font-size: 16pt;">server:</font></div><div><font style="font-size: 16pt;">  port: 3344</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">spring:</font></div><div><font style="font-size: 16pt;">  application:</font></div><div><font style="font-size: 16pt;">    name: springcloud-config-3344</font></div><div><font style="font-size: 16pt;">  cloud:</font></div><div><font style="font-size: 16pt;">    config:</font></div><div><font style="font-size: 16pt;">      server:</font></div><div><font style="font-size: 16pt;">        git:</font></div><div><font style="font-size: 16pt;">          uri: https://gitee.com/yujie.louis/springcloud-config.git #自行配置git地址，git相关使用自行学习</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">  # http://127.0.0.1:3344/application-dev.yml</font></div><div><font style="font-size: 16pt;">  # http://127.0.0.1:3344/master/config-client-dev.yml</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">  # /{application}/{profile}[/{label}]</font></div><div><font style="font-size: 16pt;">  # /{application}-{profile}.yml</font></div><div><font style="font-size: 16pt;">  # /{label}/{application}-{profile}.yml</font></div><div><font style="font-size: 16pt;">  # /{application}-{profile}.properties</font></div><div><font style="font-size: 16pt;">  # /{label}/{application}-{profile}.properties</font></div></div><div><br/></div><div><span style="font-size: 16pt;">3.主启动类</span></div><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><font style="font-size: 16pt;">package cn.edu.zzu;</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">import org.springframework.boot.SpringApplication;</font></div><div><font style="font-size: 16pt;">import org.springframework.boot.autoconfigure.SpringBootApplication;</font></div><div><font style="font-size: 16pt;">import org.springframework.cloud.config.server.EnableConfigServer;</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">@SpringBootApplication</font></div><div><font style="font-size: 16pt;">@EnableConfigServer</font></div><div><font style="font-size: 16pt;">public class ConfigServer_3344 {</font></div><div><font style="font-size: 16pt;">    public static void main(String[] args) {</font></div><div><font style="font-size: 16pt;">        SpringApplication.run(ConfigServer_3344.class, args);</font></div><div><font style="font-size: 16pt;">    }</font></div><div><font style="font-size: 16pt;">}</font></div></div><div><font style="font-size: 16pt;"><br/></font></div><div><span style="font-size: 16pt;">4.访问获取git仓库中的配置信息</span></div><ul><li><div><span style="font-size: 16pt;">本地写好的多文档块的application.yml</span></div></li></ul><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><font style="font-size: 16pt;">spring:</font></div><div><font style="font-size: 16pt;">profiles:</font></div><div><font style="font-size: 16pt;">active: dev</font></div><div><font style="font-size: 16pt;">---</font></div><div><font style="font-size: 16pt;">spring:</font></div><div><font style="font-size: 16pt;">application:</font></div><div><font style="font-size: 16pt;">name: springcloud-dev</font></div><div><font style="font-size: 16pt;">profiles: dev</font></div><div><font style="font-size: 16pt;">---</font></div><div><font style="font-size: 16pt;">spring:</font></div><div><font style="font-size: 16pt;">application:</font></div><div><font style="font-size: 16pt;">name: springcloud-test</font></div><div><font style="font-size: 16pt;">profiles: test</font></div></div><div style="text-align: center;"><img src="./index/Image [40].png" type="image/png" data-filename="Image.png" width="942"/></div><div style="text-align: left;"><a href="http://127.0.0.1:3344/application-dev.yml">http://127.0.0.1:3344/application-dev.yml</a></div><div style="text-align: center;"><img src="./index/Image [41].png" type="image/png" data-filename="Image.png"/></div><div style="text-align: center;"><br/></div><div style="text-align: left;"><a href="http://localhost:3344/application/dev/master">http://localhost:3344/application/dev/master</a></div><div style="text-align: left;"><br/></div><div style="text-align: center;"><img src="./index/Image [42].png" type="image/png" data-filename="Image.png" width="663"/></div><div style="text-align: center;"><br/></div><div style="text-align: left;"><br/></div><div style="text-align: left;"><span style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; font-size: 21.3333px; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(255, 0, 0); font-family: 微软雅黑; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: bold;">三、springcloud-config-client搭建使用</span></div><div style="text-align: left;"><br/></div><div style="text-align: left;"><span style="font-size: 16pt;">1.导入config客户端依赖</span></div><div style="text-align: left;"><br/></div><div style="text-align: left;"><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><font style="font-size: 16pt;">&lt;!--springcloud config client --&gt;</font></div><div><font style="font-size: 16pt;">&lt;dependency&gt;</font></div><div><font style="font-size: 16pt;">    &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;</font></div><div><font style="font-size: 16pt;">    &lt;artifactId&gt;spring-cloud-starter-config&lt;/artifactId&gt;</font></div><div><font style="font-size: 16pt;">    &lt;version&gt;2.1.1.RELEASE&lt;/version&gt;</font></div><div><font style="font-size: 16pt;">&lt;/dependency&gt;</font></div></div><div><br/></div></div><div style="text-align: left;"><span style="font-size: 16pt;">2.配置文件boostrap.yml(系统级别的配置) | application.yml(用户级别的配置)</span></div><div style="text-align: left;"><br/></div><div style="text-align: left;"><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><font style="font-size: 16pt;">spring:</font></div><div><font style="font-size: 16pt;">  cloud:</font></div><div><font style="font-size: 16pt;">    config:</font></div><div><font style="font-size: 16pt;">      uri: http://localhost:3344/</font></div><div><font style="font-size: 16pt;">      name: config-client</font></div><div><font style="font-size: 16pt;">      label: master</font></div><div><font style="font-size: 16pt;">      profile: dev</font></div></div><div><br/></div></div><div style="text-align: left;"><br/></div><div style="text-align: left;"><span style="font-size: 16pt;"><img src="./index/Image [43].png" type="image/png" data-filename="Image.png"/></span></div><div style="text-align: left;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: left;"><span style="font-size: 16pt;">3.在client中测试获取的配置文件信息的controller</span></div><div style="text-align: left;"><br/></div><div style="text-align: left;"><div style="box-sizing: border-box; padding: 8px; font-family: Monaco, Menlo, Consolas, &quot;Courier New&quot;, monospace; font-size: 12px; color: rgb(51, 51, 51); border-radius: 4px; background-color: rgb(251, 250, 248); border: 1px solid rgba(0, 0, 0, 0.15);-en-codeblock:true;"><div><font style="font-size: 16pt;">package cn.edu.zzu.controller;</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">import org.springframework.beans.factory.annotation.Value;</font></div><div><font style="font-size: 16pt;">import org.springframework.web.bind.annotation.GetMapping;</font></div><div><font style="font-size: 16pt;">import org.springframework.web.bind.annotation.RequestMapping;</font></div><div><font style="font-size: 16pt;">import org.springframework.web.bind.annotation.RestController;</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">@RestController</font></div><div><font style="font-size: 16pt;">@RequestMapping(&quot;/config&quot;)</font></div><div><font style="font-size: 16pt;">public class ConfigController {</font></div><div><font style="font-size: 16pt;">    @Value(&quot;${spring.application.name}&quot;)</font></div><div><font style="font-size: 16pt;">    private String applicationName ;</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">    @Value(&quot;${eureka.client.service-url.defaultZone}&quot;)</font></div><div><font style="font-size: 16pt;">    private String EurekaServer;</font></div><div><font style="font-size: 16pt;">    @Value(&quot;${server.port}&quot;)</font></div><div><font style="font-size: 16pt;">    private String serverProt;</font></div><div><font style="font-size: 16pt;"><br/></font></div><div><font style="font-size: 16pt;">    @GetMapping(&quot;/info&quot;)</font></div><div><font style="font-size: 16pt;">    public String info(){</font></div><div><font style="font-size: 16pt;">        return  &quot;  applicationName:&quot;+applicationName+</font></div><div><font style="font-size: 16pt;">                &quot;  EurekaServer:&quot;+EurekaServer+</font></div><div><font style="font-size: 16pt;">                &quot;  serverProt:&quot;+serverProt;</font></div><div><font style="font-size: 16pt;">    }</font></div><div><font style="font-size: 16pt;">}</font></div></div><div><br/></div></div><div style="text-align: left;"><span style="font-size: 16pt;"><br/></span></div><div style="text-align: center;"><span style="font-size: 16pt;"><img src="./index/Image [44].png" type="image/png" data-filename="Image.png"/></span></div><div style="text-align: center;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: left;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: left;"><font style="font-size: 16pt;"><br/></font></div><div style="text-align: left;"><span style="font-size: 16pt;">Gitee地址：</span><a href="https://gitee.com/yujie.louis/springcloud-config" style="font-size: 16pt;">https://gitee.com/yujie.louis/springcloud-config</a></div><div style="text-align: left;"><br/></div><div style="text-align: left;"><br/></div><div style="text-align: left;"><br/></div><div style="text-align: left;"><br/></div><div style="text-align: left;"><br/></div><div style="text-align: left;"><br/></div><div style="text-align: left;"><br/></div><div style="text-align: left;"><br/></div><div style="text-align: left;"><br/></div><div style="text-align: left;"><br/></div><div style="text-align: left;"><br/></div><div style="text-align: left;"><br/></div><div style="text-align: left;"><br/></div><div style="text-align: left;"><br/></div><div style="text-align: left;"><br/></div><div style="text-align: left;"><br/></div><div style="text-align: left;"><br/></div><div style="text-align: left;"><br/></div><div style="text-align: left;"><br/></div><div style="text-align: left;"><br/></div><div style="text-align: left;"><br/></div><div style="text-align: left;"><br/></div><div style="text-align: left;"><br/></div><div style="text-align: left;"><br/></div><div style="text-align: left;"><br/></div><div style="text-align: left;"><br/></div><div style="text-align: left;"><br/></div><div style="text-align: left;"><br/></div><div style="text-align: left;"><br/></div><div style="text-align: left;"><br/></div><div style="text-align: left;"><br/></div><div style="text-align: left;"><br/></div><div style="text-align: left;"><br/></div><div><br/></div></div><div><br/></div><div><br/></div></span>
</div></body></html> 